<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - /usr/include/c++/5/bits/stl_algo.h</title>
  <link rel="stylesheet" type="text/css" href="../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../../index.html">top level</a> - <a href="index.html">usr/include/c++/5/bits</a> - stl_algo.h<span style="font-size: 80%;"> (source / <a href="stl_algo.h.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">27</td>
            <td class="headerCovTableEntry">96</td>
            <td class="headerCovTableEntryLo">28.1 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:25:26</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">7</td>
            <td class="headerCovTableEntry">24</td>
            <td class="headerCovTableEntryLo">29.2 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Algorithm implementation -*- C++ -*-</a>
<span class="lineNum">       2 </span>            : 
<span class="lineNum">       3 </span>            : // Copyright (C) 2001-2015 Free Software Foundation, Inc.
<span class="lineNum">       4 </span>            : //
<span class="lineNum">       5 </span>            : // This file is part of the GNU ISO C++ Library.  This library is free
<span class="lineNum">       6 </span>            : // software; you can redistribute it and/or modify it under the
<span class="lineNum">       7 </span>            : // terms of the GNU General Public License as published by the
<span class="lineNum">       8 </span>            : // Free Software Foundation; either version 3, or (at your option)
<span class="lineNum">       9 </span>            : // any later version.
<span class="lineNum">      10 </span>            : 
<span class="lineNum">      11 </span>            : // This library is distributed in the hope that it will be useful,
<span class="lineNum">      12 </span>            : // but WITHOUT ANY WARRANTY; without even the implied warranty of
<span class="lineNum">      13 </span>            : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<span class="lineNum">      14 </span>            : // GNU General Public License for more details.
<span class="lineNum">      15 </span>            : 
<span class="lineNum">      16 </span>            : // Under Section 7 of GPL version 3, you are granted additional
<span class="lineNum">      17 </span>            : // permissions described in the GCC Runtime Library Exception, version
<span class="lineNum">      18 </span>            : // 3.1, as published by the Free Software Foundation.
<span class="lineNum">      19 </span>            : 
<span class="lineNum">      20 </span>            : // You should have received a copy of the GNU General Public License and
<span class="lineNum">      21 </span>            : // a copy of the GCC Runtime Library Exception along with this program;
<span class="lineNum">      22 </span>            : // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
<span class="lineNum">      23 </span>            : // &lt;http://www.gnu.org/licenses/&gt;.
<span class="lineNum">      24 </span>            : 
<span class="lineNum">      25 </span>            : /*
<span class="lineNum">      26 </span>            :  *
<span class="lineNum">      27 </span>            :  * Copyright (c) 1994
<span class="lineNum">      28 </span>            :  * Hewlett-Packard Company
<span class="lineNum">      29 </span>            :  *
<span class="lineNum">      30 </span>            :  * Permission to use, copy, modify, distribute and sell this software
<span class="lineNum">      31 </span>            :  * and its documentation for any purpose is hereby granted without fee,
<span class="lineNum">      32 </span>            :  * provided that the above copyright notice appear in all copies and
<span class="lineNum">      33 </span>            :  * that both that copyright notice and this permission notice appear
<span class="lineNum">      34 </span>            :  * in supporting documentation.  Hewlett-Packard Company makes no
<span class="lineNum">      35 </span>            :  * representations about the suitability of this software for any
<span class="lineNum">      36 </span>            :  * purpose.  It is provided &quot;as is&quot; without express or implied warranty.
<span class="lineNum">      37 </span>            :  *
<span class="lineNum">      38 </span>            :  *
<span class="lineNum">      39 </span>            :  * Copyright (c) 1996
<span class="lineNum">      40 </span>            :  * Silicon Graphics Computer Systems, Inc.
<span class="lineNum">      41 </span>            :  *
<span class="lineNum">      42 </span>            :  * Permission to use, copy, modify, distribute and sell this software
<span class="lineNum">      43 </span>            :  * and its documentation for any purpose is hereby granted without fee,
<span class="lineNum">      44 </span>            :  * provided that the above copyright notice appear in all copies and
<span class="lineNum">      45 </span>            :  * that both that copyright notice and this permission notice appear
<span class="lineNum">      46 </span>            :  * in supporting documentation.  Silicon Graphics makes no
<span class="lineNum">      47 </span>            :  * representations about the suitability of this software for any
<span class="lineNum">      48 </span>            :  * purpose.  It is provided &quot;as is&quot; without express or implied warranty.
<span class="lineNum">      49 </span>            :  */
<span class="lineNum">      50 </span>            : 
<span class="lineNum">      51 </span>            : /** @file bits/stl_algo.h
<span class="lineNum">      52 </span>            :  *  This is an internal header file, included by other library headers.
<span class="lineNum">      53 </span>            :  *  Do not attempt to use it directly. @headername{algorithm}
<span class="lineNum">      54 </span>            :  */
<span class="lineNum">      55 </span>            : 
<span class="lineNum">      56 </span>            : #ifndef _STL_ALGO_H
<span class="lineNum">      57 </span>            : #define _STL_ALGO_H 1
<span class="lineNum">      58 </span>            : 
<span class="lineNum">      59 </span>            : #include &lt;cstdlib&gt;             // for rand
<span class="lineNum">      60 </span>            : #include &lt;bits/algorithmfwd.h&gt;
<span class="lineNum">      61 </span>            : #include &lt;bits/stl_heap.h&gt;
<span class="lineNum">      62 </span>            : #include &lt;bits/stl_tempbuf.h&gt;  // for _Temporary_buffer
<span class="lineNum">      63 </span>            : #include &lt;bits/predefined_ops.h&gt;
<span class="lineNum">      64 </span>            : 
<span class="lineNum">      65 </span>            : #if __cplusplus &gt;= 201103L
<span class="lineNum">      66 </span>            : #include &lt;random&gt;  // for std::uniform_int_distribution
<span class="lineNum">      67 </span>            : #endif
<span class="lineNum">      68 </span>            : 
<span class="lineNum">      69 </span>            : // See concept_check.h for the __glibcxx_*_requires macros.
<span class="lineNum">      70 </span>            : 
<span class="lineNum">      71 </span>            : namespace std _GLIBCXX_VISIBILITY(default)
<span class="lineNum">      72 </span>            : {
<span class="lineNum">      73 </span>            : _GLIBCXX_BEGIN_NAMESPACE_VERSION
<span class="lineNum">      74 </span>            : 
<span class="lineNum">      75 </span>            :   /// Swaps the median value of *__a, *__b and *__c under __comp to *__result
<a name="76"><span class="lineNum">      76 </span>            :   template&lt;typename _Iterator, typename _Compare&gt;</a>
<span class="lineNum">      77 </span>            :     void
<span class="lineNum">      78 </span><span class="lineNoCov">          0 :     __move_median_to_first(_Iterator __result,_Iterator __a, _Iterator __b,</span>
<span class="lineNum">      79 </span>            :                            _Iterator __c, _Compare __comp)
<span class="lineNum">      80 </span>            :     {
<span class="lineNum">      81 </span><span class="lineNoCov">          0 :       if (__comp(__a, __b))</span>
<span class="lineNum">      82 </span>            :         {
<span class="lineNum">      83 </span><span class="lineNoCov">          0 :           if (__comp(__b, __c))</span>
<span class="lineNum">      84 </span>            :             std::iter_swap(__result, __b);
<span class="lineNum">      85 </span><span class="lineNoCov">          0 :           else if (__comp(__a, __c))</span>
<span class="lineNum">      86 </span>            :             std::iter_swap(__result, __c);
<span class="lineNum">      87 </span>            :           else
<span class="lineNum">      88 </span>            :             std::iter_swap(__result, __a);
<span class="lineNum">      89 </span>            :         }
<span class="lineNum">      90 </span><span class="lineNoCov">          0 :       else if (__comp(__a, __c))</span>
<span class="lineNum">      91 </span>            :         std::iter_swap(__result, __a);
<span class="lineNum">      92 </span><span class="lineNoCov">          0 :       else if (__comp(__b, __c))</span>
<span class="lineNum">      93 </span>            :         std::iter_swap(__result, __c);
<span class="lineNum">      94 </span>            :       else
<span class="lineNum">      95 </span>            :         std::iter_swap(__result, __b);
<span class="lineNum">      96 </span><span class="lineNoCov">          0 :     }</span>
<span class="lineNum">      97 </span>            : 
<span class="lineNum">      98 </span>            :   /// This is an overload used by find algos for the Input Iterator case.
<span class="lineNum">      99 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">     100 </span>            :     inline _InputIterator
<span class="lineNum">     101 </span>            :     __find_if(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     102 </span>            :               _Predicate __pred, input_iterator_tag)
<span class="lineNum">     103 </span>            :     {
<span class="lineNum">     104 </span>            :       while (__first != __last &amp;&amp; !__pred(__first))
<span class="lineNum">     105 </span>            :         ++__first;
<span class="lineNum">     106 </span>            :       return __first;
<span class="lineNum">     107 </span>            :     }
<span class="lineNum">     108 </span>            : 
<span class="lineNum">     109 </span>            :   /// This is an overload used by find algos for the RAI case.
<a name="110"><span class="lineNum">     110 </span>            :   template&lt;typename _RandomAccessIterator, typename _Predicate&gt;</a>
<span class="lineNum">     111 </span>            :     _RandomAccessIterator
<span class="lineNum">     112 </span><span class="lineCov">          1 :     __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,</span>
<span class="lineNum">     113 </span>            :               _Predicate __pred, random_access_iterator_tag)
<span class="lineNum">     114 </span>            :     {
<span class="lineNum">     115 </span>            :       typename iterator_traits&lt;_RandomAccessIterator&gt;::difference_type
<span class="lineNum">     116 </span><span class="lineCov">          1 :         __trip_count = (__last - __first) &gt;&gt; 2;</span>
<span class="lineNum">     117 </span>            : 
<span class="lineNum">     118 </span><span class="lineCov">          1 :       for (; __trip_count &gt; 0; --__trip_count)</span>
<span class="lineNum">     119 </span>            :         {
<span class="lineNum">     120 </span><span class="lineNoCov">          0 :           if (__pred(__first))</span>
<span class="lineNum">     121 </span><span class="lineNoCov">          0 :             return __first;</span>
<span class="lineNum">     122 </span>            :           ++__first;
<span class="lineNum">     123 </span>            : 
<span class="lineNum">     124 </span><span class="lineNoCov">          0 :           if (__pred(__first))</span>
<span class="lineNum">     125 </span><span class="lineNoCov">          0 :             return __first;</span>
<span class="lineNum">     126 </span>            :           ++__first;
<span class="lineNum">     127 </span>            : 
<span class="lineNum">     128 </span><span class="lineNoCov">          0 :           if (__pred(__first))</span>
<span class="lineNum">     129 </span><span class="lineNoCov">          0 :             return __first;</span>
<span class="lineNum">     130 </span>            :           ++__first;
<span class="lineNum">     131 </span>            : 
<span class="lineNum">     132 </span><span class="lineNoCov">          0 :           if (__pred(__first))</span>
<span class="lineNum">     133 </span><span class="lineNoCov">          0 :             return __first;</span>
<span class="lineNum">     134 </span>            :           ++__first;
<span class="lineNum">     135 </span>            :         }
<span class="lineNum">     136 </span>            : 
<span class="lineNum">     137 </span><span class="lineCov">          1 :       switch (__last - __first)</span>
<span class="lineNum">     138 </span>            :         {
<span class="lineNum">     139 </span>            :         case 3:
<span class="lineNum">     140 </span><span class="lineNoCov">          0 :           if (__pred(__first))</span>
<span class="lineNum">     141 </span><span class="lineNoCov">          0 :             return __first;</span>
<span class="lineNum">     142 </span>            :           ++__first;
<span class="lineNum">     143 </span>            :         case 2:
<span class="lineNum">     144 </span><span class="lineNoCov">          0 :           if (__pred(__first))</span>
<span class="lineNum">     145 </span><span class="lineNoCov">          0 :             return __first;</span>
<span class="lineNum">     146 </span>            :           ++__first;
<span class="lineNum">     147 </span>            :         case 1:
<span class="lineNum">     148 </span><span class="lineNoCov">          0 :           if (__pred(__first))</span>
<span class="lineNum">     149 </span><span class="lineNoCov">          0 :             return __first;</span>
<span class="lineNum">     150 </span>            :           ++__first;
<span class="lineNum">     151 </span>            :         case 0:
<span class="lineNum">     152 </span>            :         default:
<span class="lineNum">     153 </span><span class="lineCov">          1 :           return __last;</span>
<span class="lineNum">     154 </span>            :         }
<span class="lineNum">     155 </span>            :     }
<span class="lineNum">     156 </span>            : 
<a name="157"><span class="lineNum">     157 </span>            :   template&lt;typename _Iterator, typename _Predicate&gt;</a>
<span class="lineNum">     158 </span>            :     inline _Iterator
<span class="lineNum">     159 </span><span class="lineCov">          1 :     __find_if(_Iterator __first, _Iterator __last, _Predicate __pred)</span>
<span class="lineNum">     160 </span>            :     {
<span class="lineNum">     161 </span><span class="lineCov">          1 :       return __find_if(__first, __last, __pred,</span>
<span class="lineNum">     162 </span><span class="lineCov">          2 :                        std::__iterator_category(__first));</span>
<span class="lineNum">     163 </span>            :     }
<span class="lineNum">     164 </span>            : 
<span class="lineNum">     165 </span>            :   /// Provided for stable_partition to use.
<span class="lineNum">     166 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">     167 </span>            :     inline _InputIterator
<span class="lineNum">     168 </span>            :     __find_if_not(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     169 </span>            :                   _Predicate __pred)
<span class="lineNum">     170 </span>            :     {
<span class="lineNum">     171 </span>            :       return std::__find_if(__first, __last,
<span class="lineNum">     172 </span>            :                             __gnu_cxx::__ops::__negate(__pred),
<span class="lineNum">     173 </span>            :                             std::__iterator_category(__first));
<span class="lineNum">     174 </span>            :     }
<span class="lineNum">     175 </span>            : 
<span class="lineNum">     176 </span>            :   /// Like find_if_not(), but uses and updates a count of the
<span class="lineNum">     177 </span>            :   /// remaining range length instead of comparing against an end
<span class="lineNum">     178 </span>            :   /// iterator.
<span class="lineNum">     179 </span>            :   template&lt;typename _InputIterator, typename _Predicate, typename _Distance&gt;
<span class="lineNum">     180 </span>            :     _InputIterator
<span class="lineNum">     181 </span>            :     __find_if_not_n(_InputIterator __first, _Distance&amp; __len, _Predicate __pred)
<span class="lineNum">     182 </span>            :     {
<span class="lineNum">     183 </span>            :       for (; __len; --__len, ++__first)
<span class="lineNum">     184 </span>            :         if (!__pred(__first))
<span class="lineNum">     185 </span>            :           break;
<span class="lineNum">     186 </span>            :       return __first;
<span class="lineNum">     187 </span>            :     }
<span class="lineNum">     188 </span>            : 
<span class="lineNum">     189 </span>            :   // set_difference
<span class="lineNum">     190 </span>            :   // set_intersection
<span class="lineNum">     191 </span>            :   // set_symmetric_difference
<span class="lineNum">     192 </span>            :   // set_union
<span class="lineNum">     193 </span>            :   // for_each
<span class="lineNum">     194 </span>            :   // find
<span class="lineNum">     195 </span>            :   // find_if
<span class="lineNum">     196 </span>            :   // find_first_of
<span class="lineNum">     197 </span>            :   // adjacent_find
<span class="lineNum">     198 </span>            :   // count
<span class="lineNum">     199 </span>            :   // count_if
<span class="lineNum">     200 </span>            :   // search
<span class="lineNum">     201 </span>            : 
<span class="lineNum">     202 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2,
<span class="lineNum">     203 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">     204 </span>            :     _ForwardIterator1
<span class="lineNum">     205 </span>            :     __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">     206 </span>            :              _ForwardIterator2 __first2, _ForwardIterator2 __last2,
<span class="lineNum">     207 </span>            :              _BinaryPredicate  __predicate)
<span class="lineNum">     208 </span>            :     {
<span class="lineNum">     209 </span>            :       // Test for empty ranges
<span class="lineNum">     210 </span>            :       if (__first1 == __last1 || __first2 == __last2)
<span class="lineNum">     211 </span>            :         return __first1;
<span class="lineNum">     212 </span>            : 
<span class="lineNum">     213 </span>            :       // Test for a pattern of length 1.
<span class="lineNum">     214 </span>            :       _ForwardIterator2 __p1(__first2);
<span class="lineNum">     215 </span>            :       if (++__p1 == __last2)
<span class="lineNum">     216 </span>            :         return std::__find_if(__first1, __last1,
<span class="lineNum">     217 </span>            :                 __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
<span class="lineNum">     218 </span>            : 
<span class="lineNum">     219 </span>            :       // General case.
<span class="lineNum">     220 </span>            :       _ForwardIterator2 __p;
<span class="lineNum">     221 </span>            :       _ForwardIterator1 __current = __first1;
<span class="lineNum">     222 </span>            : 
<span class="lineNum">     223 </span>            :       for (;;)
<span class="lineNum">     224 </span>            :         {
<span class="lineNum">     225 </span>            :           __first1 =
<span class="lineNum">     226 </span>            :             std::__find_if(__first1, __last1,
<span class="lineNum">     227 </span>            :                 __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
<span class="lineNum">     228 </span>            : 
<span class="lineNum">     229 </span>            :           if (__first1 == __last1)
<span class="lineNum">     230 </span>            :             return __last1;
<span class="lineNum">     231 </span>            : 
<span class="lineNum">     232 </span>            :           __p = __p1;
<span class="lineNum">     233 </span>            :           __current = __first1;
<span class="lineNum">     234 </span>            :           if (++__current == __last1)
<span class="lineNum">     235 </span>            :             return __last1;
<span class="lineNum">     236 </span>            : 
<span class="lineNum">     237 </span>            :           while (__predicate(__current, __p))
<span class="lineNum">     238 </span>            :             {
<span class="lineNum">     239 </span>            :               if (++__p == __last2)
<span class="lineNum">     240 </span>            :                 return __first1;
<span class="lineNum">     241 </span>            :               if (++__current == __last1)
<span class="lineNum">     242 </span>            :                 return __last1;
<span class="lineNum">     243 </span>            :             }
<span class="lineNum">     244 </span>            :           ++__first1;
<span class="lineNum">     245 </span>            :         }
<span class="lineNum">     246 </span>            :       return __first1;
<span class="lineNum">     247 </span>            :     }
<span class="lineNum">     248 </span>            : 
<span class="lineNum">     249 </span>            :   // search_n
<span class="lineNum">     250 </span>            : 
<span class="lineNum">     251 </span>            :   /**
<span class="lineNum">     252 </span>            :    *  This is an helper function for search_n overloaded for forward iterators.
<span class="lineNum">     253 </span>            :   */
<span class="lineNum">     254 </span>            :   template&lt;typename _ForwardIterator, typename _Integer,
<span class="lineNum">     255 </span>            :            typename _UnaryPredicate&gt;
<span class="lineNum">     256 </span>            :     _ForwardIterator
<span class="lineNum">     257 </span>            :     __search_n_aux(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">     258 </span>            :                    _Integer __count, _UnaryPredicate __unary_pred,
<span class="lineNum">     259 </span>            :                    std::forward_iterator_tag)
<span class="lineNum">     260 </span>            :     {
<span class="lineNum">     261 </span>            :       __first = std::__find_if(__first, __last, __unary_pred);
<span class="lineNum">     262 </span>            :       while (__first != __last)
<span class="lineNum">     263 </span>            :         {
<span class="lineNum">     264 </span>            :           typename iterator_traits&lt;_ForwardIterator&gt;::difference_type
<span class="lineNum">     265 </span>            :             __n = __count;
<span class="lineNum">     266 </span>            :           _ForwardIterator __i = __first;
<span class="lineNum">     267 </span>            :           ++__i;
<span class="lineNum">     268 </span>            :           while (__i != __last &amp;&amp; __n != 1 &amp;&amp; __unary_pred(__i))
<span class="lineNum">     269 </span>            :             {
<span class="lineNum">     270 </span>            :               ++__i;
<span class="lineNum">     271 </span>            :               --__n;
<span class="lineNum">     272 </span>            :             }
<span class="lineNum">     273 </span>            :           if (__n == 1)
<span class="lineNum">     274 </span>            :             return __first;
<span class="lineNum">     275 </span>            :           if (__i == __last)
<span class="lineNum">     276 </span>            :             return __last;
<span class="lineNum">     277 </span>            :           __first = std::__find_if(++__i, __last, __unary_pred);
<span class="lineNum">     278 </span>            :         }
<span class="lineNum">     279 </span>            :       return __last;
<span class="lineNum">     280 </span>            :     }
<span class="lineNum">     281 </span>            : 
<span class="lineNum">     282 </span>            :   /**
<span class="lineNum">     283 </span>            :    *  This is an helper function for search_n overloaded for random access
<span class="lineNum">     284 </span>            :    *  iterators.
<span class="lineNum">     285 </span>            :   */
<span class="lineNum">     286 </span>            :   template&lt;typename _RandomAccessIter, typename _Integer,
<span class="lineNum">     287 </span>            :            typename _UnaryPredicate&gt;
<span class="lineNum">     288 </span>            :     _RandomAccessIter
<span class="lineNum">     289 </span>            :     __search_n_aux(_RandomAccessIter __first, _RandomAccessIter __last,
<span class="lineNum">     290 </span>            :                    _Integer __count, _UnaryPredicate __unary_pred,
<span class="lineNum">     291 </span>            :                    std::random_access_iterator_tag)
<span class="lineNum">     292 </span>            :     {
<span class="lineNum">     293 </span>            :       typedef typename std::iterator_traits&lt;_RandomAccessIter&gt;::difference_type
<span class="lineNum">     294 </span>            :         _DistanceType;
<span class="lineNum">     295 </span>            : 
<span class="lineNum">     296 </span>            :       _DistanceType __tailSize = __last - __first;
<span class="lineNum">     297 </span>            :       _DistanceType __remainder = __count;
<span class="lineNum">     298 </span>            : 
<span class="lineNum">     299 </span>            :       while (__remainder &lt;= __tailSize) // the main loop...
<span class="lineNum">     300 </span>            :         {
<span class="lineNum">     301 </span>            :           __first += __remainder;
<span class="lineNum">     302 </span>            :           __tailSize -= __remainder;
<span class="lineNum">     303 </span>            :           // __first here is always pointing to one past the last element of
<span class="lineNum">     304 </span>            :           // next possible match.
<span class="lineNum">     305 </span>            :           _RandomAccessIter __backTrack = __first; 
<span class="lineNum">     306 </span>            :           while (__unary_pred(--__backTrack))
<span class="lineNum">     307 </span>            :             {
<span class="lineNum">     308 </span>            :               if (--__remainder == 0)
<span class="lineNum">     309 </span>            :                 return (__first - __count); // Success
<span class="lineNum">     310 </span>            :             }
<span class="lineNum">     311 </span>            :           __remainder = __count + 1 - (__first - __backTrack);
<span class="lineNum">     312 </span>            :         }
<span class="lineNum">     313 </span>            :       return __last; // Failure
<span class="lineNum">     314 </span>            :     }
<span class="lineNum">     315 </span>            : 
<span class="lineNum">     316 </span>            :   template&lt;typename _ForwardIterator, typename _Integer,
<span class="lineNum">     317 </span>            :            typename _UnaryPredicate&gt;
<span class="lineNum">     318 </span>            :     _ForwardIterator
<span class="lineNum">     319 </span>            :     __search_n(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">     320 </span>            :                _Integer __count,
<span class="lineNum">     321 </span>            :                _UnaryPredicate __unary_pred)
<span class="lineNum">     322 </span>            :     {
<span class="lineNum">     323 </span>            :       if (__count &lt;= 0)
<span class="lineNum">     324 </span>            :         return __first;
<span class="lineNum">     325 </span>            : 
<span class="lineNum">     326 </span>            :       if (__count == 1)
<span class="lineNum">     327 </span>            :         return std::__find_if(__first, __last, __unary_pred);
<span class="lineNum">     328 </span>            : 
<span class="lineNum">     329 </span>            :       return std::__search_n_aux(__first, __last, __count, __unary_pred,
<span class="lineNum">     330 </span>            :                                  std::__iterator_category(__first));
<span class="lineNum">     331 </span>            :     }
<span class="lineNum">     332 </span>            : 
<span class="lineNum">     333 </span>            :   // find_end for forward iterators.
<span class="lineNum">     334 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2,
<span class="lineNum">     335 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">     336 </span>            :     _ForwardIterator1
<span class="lineNum">     337 </span>            :     __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">     338 </span>            :                _ForwardIterator2 __first2, _ForwardIterator2 __last2,
<span class="lineNum">     339 </span>            :                forward_iterator_tag, forward_iterator_tag,
<span class="lineNum">     340 </span>            :                _BinaryPredicate __comp)
<span class="lineNum">     341 </span>            :     {
<span class="lineNum">     342 </span>            :       if (__first2 == __last2)
<span class="lineNum">     343 </span>            :         return __last1;
<span class="lineNum">     344 </span>            : 
<span class="lineNum">     345 </span>            :       _ForwardIterator1 __result = __last1;
<span class="lineNum">     346 </span>            :       while (1)
<span class="lineNum">     347 </span>            :         {
<span class="lineNum">     348 </span>            :           _ForwardIterator1 __new_result
<span class="lineNum">     349 </span>            :             = std::__search(__first1, __last1, __first2, __last2, __comp);
<span class="lineNum">     350 </span>            :           if (__new_result == __last1)
<span class="lineNum">     351 </span>            :             return __result;
<span class="lineNum">     352 </span>            :           else
<span class="lineNum">     353 </span>            :             {
<span class="lineNum">     354 </span>            :               __result = __new_result;
<span class="lineNum">     355 </span>            :               __first1 = __new_result;
<span class="lineNum">     356 </span>            :               ++__first1;
<span class="lineNum">     357 </span>            :             }
<span class="lineNum">     358 </span>            :         }
<span class="lineNum">     359 </span>            :     }
<span class="lineNum">     360 </span>            : 
<span class="lineNum">     361 </span>            :   // find_end for bidirectional iterators (much faster).
<span class="lineNum">     362 </span>            :   template&lt;typename _BidirectionalIterator1, typename _BidirectionalIterator2,
<span class="lineNum">     363 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">     364 </span>            :     _BidirectionalIterator1
<span class="lineNum">     365 </span>            :     __find_end(_BidirectionalIterator1 __first1,
<span class="lineNum">     366 </span>            :                _BidirectionalIterator1 __last1,
<span class="lineNum">     367 </span>            :                _BidirectionalIterator2 __first2,
<span class="lineNum">     368 </span>            :                _BidirectionalIterator2 __last2,
<span class="lineNum">     369 </span>            :                bidirectional_iterator_tag, bidirectional_iterator_tag,
<span class="lineNum">     370 </span>            :                _BinaryPredicate __comp)
<span class="lineNum">     371 </span>            :     {
<span class="lineNum">     372 </span>            :       // concept requirements
<span class="lineNum">     373 </span>            :       __glibcxx_function_requires(_BidirectionalIteratorConcept&lt;
<span class="lineNum">     374 </span>            :                                   _BidirectionalIterator1&gt;)
<span class="lineNum">     375 </span>            :       __glibcxx_function_requires(_BidirectionalIteratorConcept&lt;
<span class="lineNum">     376 </span>            :                                   _BidirectionalIterator2&gt;)
<span class="lineNum">     377 </span>            : 
<span class="lineNum">     378 </span>            :       typedef reverse_iterator&lt;_BidirectionalIterator1&gt; _RevIterator1;
<span class="lineNum">     379 </span>            :       typedef reverse_iterator&lt;_BidirectionalIterator2&gt; _RevIterator2;
<span class="lineNum">     380 </span>            : 
<span class="lineNum">     381 </span>            :       _RevIterator1 __rlast1(__first1);
<span class="lineNum">     382 </span>            :       _RevIterator2 __rlast2(__first2);
<span class="lineNum">     383 </span>            :       _RevIterator1 __rresult = std::__search(_RevIterator1(__last1), __rlast1,
<span class="lineNum">     384 </span>            :                                               _RevIterator2(__last2), __rlast2,
<span class="lineNum">     385 </span>            :                                               __comp);
<span class="lineNum">     386 </span>            : 
<span class="lineNum">     387 </span>            :       if (__rresult == __rlast1)
<span class="lineNum">     388 </span>            :         return __last1;
<span class="lineNum">     389 </span>            :       else
<span class="lineNum">     390 </span>            :         {
<span class="lineNum">     391 </span>            :           _BidirectionalIterator1 __result = __rresult.base();
<span class="lineNum">     392 </span>            :           std::advance(__result, -std::distance(__first2, __last2));
<span class="lineNum">     393 </span>            :           return __result;
<span class="lineNum">     394 </span>            :         }
<span class="lineNum">     395 </span>            :     }
<span class="lineNum">     396 </span>            : 
<span class="lineNum">     397 </span>            :   /**
<span class="lineNum">     398 </span>            :    *  @brief  Find last matching subsequence in a sequence.
<span class="lineNum">     399 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">     400 </span>            :    *  @param  __first1  Start of range to search.
<span class="lineNum">     401 </span>            :    *  @param  __last1   End of range to search.
<span class="lineNum">     402 </span>            :    *  @param  __first2  Start of sequence to match.
<span class="lineNum">     403 </span>            :    *  @param  __last2   End of sequence to match.
<span class="lineNum">     404 </span>            :    *  @return   The last iterator @c i in the range
<span class="lineNum">     405 </span>            :    *  @p [__first1,__last1-(__last2-__first2)) such that @c *(i+N) ==
<span class="lineNum">     406 </span>            :    *  @p *(__first2+N) for each @c N in the range @p
<span class="lineNum">     407 </span>            :    *  [0,__last2-__first2), or @p __last1 if no such iterator exists.
<span class="lineNum">     408 </span>            :    *
<span class="lineNum">     409 </span>            :    *  Searches the range @p [__first1,__last1) for a sub-sequence that
<span class="lineNum">     410 </span>            :    *  compares equal value-by-value with the sequence given by @p
<span class="lineNum">     411 </span>            :    *  [__first2,__last2) and returns an iterator to the __first
<span class="lineNum">     412 </span>            :    *  element of the sub-sequence, or @p __last1 if the sub-sequence
<span class="lineNum">     413 </span>            :    *  is not found.  The sub-sequence will be the last such
<span class="lineNum">     414 </span>            :    *  subsequence contained in [__first1,__last1).
<span class="lineNum">     415 </span>            :    *
<span class="lineNum">     416 </span>            :    *  Because the sub-sequence must lie completely within the range @p
<span class="lineNum">     417 </span>            :    *  [__first1,__last1) it must start at a position less than @p
<span class="lineNum">     418 </span>            :    *  __last1-(__last2-__first2) where @p __last2-__first2 is the
<span class="lineNum">     419 </span>            :    *  length of the sub-sequence.  This means that the returned
<span class="lineNum">     420 </span>            :    *  iterator @c i will be in the range @p
<span class="lineNum">     421 </span>            :    *  [__first1,__last1-(__last2-__first2))
<span class="lineNum">     422 </span>            :   */
<span class="lineNum">     423 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2&gt;
<span class="lineNum">     424 </span>            :     inline _ForwardIterator1
<span class="lineNum">     425 </span>            :     find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">     426 </span>            :              _ForwardIterator2 __first2, _ForwardIterator2 __last2)
<span class="lineNum">     427 </span>            :     {
<span class="lineNum">     428 </span>            :       // concept requirements
<span class="lineNum">     429 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator1&gt;)
<span class="lineNum">     430 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator2&gt;)
<span class="lineNum">     431 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">     432 </span>            :             typename iterator_traits&lt;_ForwardIterator1&gt;::value_type,
<span class="lineNum">     433 </span>            :             typename iterator_traits&lt;_ForwardIterator2&gt;::value_type&gt;)
<span class="lineNum">     434 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">     435 </span>            :       __glibcxx_requires_valid_range(__first2, __last2);
<span class="lineNum">     436 </span>            : 
<span class="lineNum">     437 </span>            :       return std::__find_end(__first1, __last1, __first2, __last2,
<span class="lineNum">     438 </span>            :                              std::__iterator_category(__first1),
<span class="lineNum">     439 </span>            :                              std::__iterator_category(__first2),
<span class="lineNum">     440 </span>            :                              __gnu_cxx::__ops::__iter_equal_to_iter());
<span class="lineNum">     441 </span>            :     }
<span class="lineNum">     442 </span>            : 
<span class="lineNum">     443 </span>            :   /**
<span class="lineNum">     444 </span>            :    *  @brief  Find last matching subsequence in a sequence using a predicate.
<span class="lineNum">     445 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">     446 </span>            :    *  @param  __first1  Start of range to search.
<span class="lineNum">     447 </span>            :    *  @param  __last1   End of range to search.
<span class="lineNum">     448 </span>            :    *  @param  __first2  Start of sequence to match.
<span class="lineNum">     449 </span>            :    *  @param  __last2   End of sequence to match.
<span class="lineNum">     450 </span>            :    *  @param  __comp    The predicate to use.
<span class="lineNum">     451 </span>            :    *  @return The last iterator @c i in the range @p
<span class="lineNum">     452 </span>            :    *  [__first1,__last1-(__last2-__first2)) such that @c
<span class="lineNum">     453 </span>            :    *  predicate(*(i+N), @p (__first2+N)) is true for each @c N in the
<span class="lineNum">     454 </span>            :    *  range @p [0,__last2-__first2), or @p __last1 if no such iterator
<span class="lineNum">     455 </span>            :    *  exists.
<span class="lineNum">     456 </span>            :    *
<span class="lineNum">     457 </span>            :    *  Searches the range @p [__first1,__last1) for a sub-sequence that
<span class="lineNum">     458 </span>            :    *  compares equal value-by-value with the sequence given by @p
<span class="lineNum">     459 </span>            :    *  [__first2,__last2) using comp as a predicate and returns an
<span class="lineNum">     460 </span>            :    *  iterator to the first element of the sub-sequence, or @p __last1
<span class="lineNum">     461 </span>            :    *  if the sub-sequence is not found.  The sub-sequence will be the
<span class="lineNum">     462 </span>            :    *  last such subsequence contained in [__first,__last1).
<span class="lineNum">     463 </span>            :    *
<span class="lineNum">     464 </span>            :    *  Because the sub-sequence must lie completely within the range @p
<span class="lineNum">     465 </span>            :    *  [__first1,__last1) it must start at a position less than @p
<span class="lineNum">     466 </span>            :    *  __last1-(__last2-__first2) where @p __last2-__first2 is the
<span class="lineNum">     467 </span>            :    *  length of the sub-sequence.  This means that the returned
<span class="lineNum">     468 </span>            :    *  iterator @c i will be in the range @p
<span class="lineNum">     469 </span>            :    *  [__first1,__last1-(__last2-__first2))
<span class="lineNum">     470 </span>            :   */
<span class="lineNum">     471 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2,
<span class="lineNum">     472 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">     473 </span>            :     inline _ForwardIterator1
<span class="lineNum">     474 </span>            :     find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">     475 </span>            :              _ForwardIterator2 __first2, _ForwardIterator2 __last2,
<span class="lineNum">     476 </span>            :              _BinaryPredicate __comp)
<span class="lineNum">     477 </span>            :     {
<span class="lineNum">     478 </span>            :       // concept requirements
<span class="lineNum">     479 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator1&gt;)
<span class="lineNum">     480 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator2&gt;)
<span class="lineNum">     481 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">     482 </span>            :             typename iterator_traits&lt;_ForwardIterator1&gt;::value_type,
<span class="lineNum">     483 </span>            :             typename iterator_traits&lt;_ForwardIterator2&gt;::value_type&gt;)
<span class="lineNum">     484 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">     485 </span>            :       __glibcxx_requires_valid_range(__first2, __last2);
<span class="lineNum">     486 </span>            : 
<span class="lineNum">     487 </span>            :       return std::__find_end(__first1, __last1, __first2, __last2,
<span class="lineNum">     488 </span>            :                              std::__iterator_category(__first1),
<span class="lineNum">     489 </span>            :                              std::__iterator_category(__first2),
<span class="lineNum">     490 </span>            :                              __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">     491 </span>            :     }
<span class="lineNum">     492 </span>            : 
<span class="lineNum">     493 </span>            : #if __cplusplus &gt;= 201103L
<span class="lineNum">     494 </span>            :   /**
<span class="lineNum">     495 </span>            :    *  @brief  Checks that a predicate is true for all the elements
<span class="lineNum">     496 </span>            :    *          of a sequence.
<span class="lineNum">     497 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">     498 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">     499 </span>            :    *  @param  __last    An input iterator.
<span class="lineNum">     500 </span>            :    *  @param  __pred    A predicate.
<span class="lineNum">     501 </span>            :    *  @return  True if the check is true, false otherwise.
<span class="lineNum">     502 </span>            :    *
<span class="lineNum">     503 </span>            :    *  Returns true if @p __pred is true for each element in the range
<span class="lineNum">     504 </span>            :    *  @p [__first,__last), and false otherwise.
<span class="lineNum">     505 </span>            :   */
<span class="lineNum">     506 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">     507 </span>            :     inline bool
<span class="lineNum">     508 </span>            :     all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
<span class="lineNum">     509 </span>            :     { return __last == std::find_if_not(__first, __last, __pred); }
<span class="lineNum">     510 </span>            : 
<span class="lineNum">     511 </span>            :   /**
<span class="lineNum">     512 </span>            :    *  @brief  Checks that a predicate is false for all the elements
<span class="lineNum">     513 </span>            :    *          of a sequence.
<span class="lineNum">     514 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">     515 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">     516 </span>            :    *  @param  __last    An input iterator.
<span class="lineNum">     517 </span>            :    *  @param  __pred    A predicate.
<span class="lineNum">     518 </span>            :    *  @return  True if the check is true, false otherwise.
<span class="lineNum">     519 </span>            :    *
<span class="lineNum">     520 </span>            :    *  Returns true if @p __pred is false for each element in the range
<span class="lineNum">     521 </span>            :    *  @p [__first,__last), and false otherwise.
<span class="lineNum">     522 </span>            :   */
<span class="lineNum">     523 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">     524 </span>            :     inline bool
<span class="lineNum">     525 </span>            :     none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
<span class="lineNum">     526 </span>            :     { return __last == _GLIBCXX_STD_A::find_if(__first, __last, __pred); }
<span class="lineNum">     527 </span>            : 
<span class="lineNum">     528 </span>            :   /**
<span class="lineNum">     529 </span>            :    *  @brief  Checks that a predicate is false for at least an element
<span class="lineNum">     530 </span>            :    *          of a sequence.
<span class="lineNum">     531 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">     532 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">     533 </span>            :    *  @param  __last    An input iterator.
<span class="lineNum">     534 </span>            :    *  @param  __pred    A predicate.
<span class="lineNum">     535 </span>            :    *  @return  True if the check is true, false otherwise.
<span class="lineNum">     536 </span>            :    *
<span class="lineNum">     537 </span>            :    *  Returns true if an element exists in the range @p
<span class="lineNum">     538 </span>            :    *  [__first,__last) such that @p __pred is true, and false
<span class="lineNum">     539 </span>            :    *  otherwise.
<span class="lineNum">     540 </span>            :   */
<span class="lineNum">     541 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">     542 </span>            :     inline bool
<span class="lineNum">     543 </span>            :     any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
<span class="lineNum">     544 </span>            :     { return !std::none_of(__first, __last, __pred); }
<span class="lineNum">     545 </span>            : 
<span class="lineNum">     546 </span>            :   /**
<span class="lineNum">     547 </span>            :    *  @brief  Find the first element in a sequence for which a
<span class="lineNum">     548 </span>            :    *          predicate is false.
<span class="lineNum">     549 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">     550 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">     551 </span>            :    *  @param  __last   An input iterator.
<span class="lineNum">     552 </span>            :    *  @param  __pred   A predicate.
<span class="lineNum">     553 </span>            :    *  @return   The first iterator @c i in the range @p [__first,__last)
<span class="lineNum">     554 </span>            :    *  such that @p __pred(*i) is false, or @p __last if no such iterator exists.
<span class="lineNum">     555 </span>            :   */
<span class="lineNum">     556 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">     557 </span>            :     inline _InputIterator
<span class="lineNum">     558 </span>            :     find_if_not(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     559 </span>            :                 _Predicate __pred)
<span class="lineNum">     560 </span>            :     {
<span class="lineNum">     561 </span>            :       // concept requirements
<span class="lineNum">     562 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">     563 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">     564 </span>            :               typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     565 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">     566 </span>            :       return std::__find_if_not(__first, __last,
<span class="lineNum">     567 </span>            :                                 __gnu_cxx::__ops::__pred_iter(__pred));
<span class="lineNum">     568 </span>            :     }
<span class="lineNum">     569 </span>            : 
<span class="lineNum">     570 </span>            :   /**
<span class="lineNum">     571 </span>            :    *  @brief  Checks whether the sequence is partitioned.
<span class="lineNum">     572 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     573 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">     574 </span>            :    *  @param  __last   An input iterator.
<span class="lineNum">     575 </span>            :    *  @param  __pred   A predicate.
<span class="lineNum">     576 </span>            :    *  @return  True if the range @p [__first,__last) is partioned by @p __pred,
<span class="lineNum">     577 </span>            :    *  i.e. if all elements that satisfy @p __pred appear before those that
<span class="lineNum">     578 </span>            :    *  do not.
<span class="lineNum">     579 </span>            :   */
<span class="lineNum">     580 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">     581 </span>            :     inline bool
<span class="lineNum">     582 </span>            :     is_partitioned(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     583 </span>            :                    _Predicate __pred)
<span class="lineNum">     584 </span>            :     {
<span class="lineNum">     585 </span>            :       __first = std::find_if_not(__first, __last, __pred);
<span class="lineNum">     586 </span>            :       return std::none_of(__first, __last, __pred);
<span class="lineNum">     587 </span>            :     }
<span class="lineNum">     588 </span>            : 
<span class="lineNum">     589 </span>            :   /**
<span class="lineNum">     590 </span>            :    *  @brief  Find the partition point of a partitioned range.
<span class="lineNum">     591 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     592 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">     593 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">     594 </span>            :    *  @param  __pred    A predicate.
<span class="lineNum">     595 </span>            :    *  @return  An iterator @p mid such that @p all_of(__first, mid, __pred)
<span class="lineNum">     596 </span>            :    *           and @p none_of(mid, __last, __pred) are both true.
<span class="lineNum">     597 </span>            :   */
<span class="lineNum">     598 </span>            :   template&lt;typename _ForwardIterator, typename _Predicate&gt;
<span class="lineNum">     599 </span>            :     _ForwardIterator
<span class="lineNum">     600 </span>            :     partition_point(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">     601 </span>            :                     _Predicate __pred)
<span class="lineNum">     602 </span>            :     {
<span class="lineNum">     603 </span>            :       // concept requirements
<span class="lineNum">     604 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">     605 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">     606 </span>            :               typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">     607 </span>            : 
<span class="lineNum">     608 </span>            :       // A specific debug-mode test will be necessary...
<span class="lineNum">     609 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">     610 </span>            : 
<span class="lineNum">     611 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::difference_type
<span class="lineNum">     612 </span>            :         _DistanceType;
<span class="lineNum">     613 </span>            : 
<span class="lineNum">     614 </span>            :       _DistanceType __len = std::distance(__first, __last);
<span class="lineNum">     615 </span>            :       _DistanceType __half;
<span class="lineNum">     616 </span>            :       _ForwardIterator __middle;
<span class="lineNum">     617 </span>            : 
<span class="lineNum">     618 </span>            :       while (__len &gt; 0)
<span class="lineNum">     619 </span>            :         {
<span class="lineNum">     620 </span>            :           __half = __len &gt;&gt; 1;
<span class="lineNum">     621 </span>            :           __middle = __first;
<span class="lineNum">     622 </span>            :           std::advance(__middle, __half);
<span class="lineNum">     623 </span>            :           if (__pred(*__middle))
<span class="lineNum">     624 </span>            :             {
<span class="lineNum">     625 </span>            :               __first = __middle;
<span class="lineNum">     626 </span>            :               ++__first;
<span class="lineNum">     627 </span>            :               __len = __len - __half - 1;
<span class="lineNum">     628 </span>            :             }
<span class="lineNum">     629 </span>            :           else
<span class="lineNum">     630 </span>            :             __len = __half;
<span class="lineNum">     631 </span>            :         }
<span class="lineNum">     632 </span>            :       return __first;
<span class="lineNum">     633 </span>            :     }
<span class="lineNum">     634 </span>            : #endif
<span class="lineNum">     635 </span>            : 
<span class="lineNum">     636 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">     637 </span>            :            typename _Predicate&gt;
<span class="lineNum">     638 </span>            :     _OutputIterator
<span class="lineNum">     639 </span>            :     __remove_copy_if(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     640 </span>            :                      _OutputIterator __result, _Predicate __pred)
<span class="lineNum">     641 </span>            :     {
<span class="lineNum">     642 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">     643 </span>            :         if (!__pred(__first))
<span class="lineNum">     644 </span>            :           {
<span class="lineNum">     645 </span>            :             *__result = *__first;
<span class="lineNum">     646 </span>            :             ++__result;
<span class="lineNum">     647 </span>            :           }
<span class="lineNum">     648 </span>            :       return __result;
<span class="lineNum">     649 </span>            :     }
<span class="lineNum">     650 </span>            : 
<span class="lineNum">     651 </span>            :   /**
<span class="lineNum">     652 </span>            :    *  @brief Copy a sequence, removing elements of a given value.
<span class="lineNum">     653 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     654 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">     655 </span>            :    *  @param  __last    An input iterator.
<span class="lineNum">     656 </span>            :    *  @param  __result  An output iterator.
<span class="lineNum">     657 </span>            :    *  @param  __value   The value to be removed.
<span class="lineNum">     658 </span>            :    *  @return   An iterator designating the end of the resulting sequence.
<span class="lineNum">     659 </span>            :    *
<span class="lineNum">     660 </span>            :    *  Copies each element in the range @p [__first,__last) not equal
<span class="lineNum">     661 </span>            :    *  to @p __value to the range beginning at @p __result.
<span class="lineNum">     662 </span>            :    *  remove_copy() is stable, so the relative order of elements that
<span class="lineNum">     663 </span>            :    *  are copied is unchanged.
<span class="lineNum">     664 </span>            :   */
<span class="lineNum">     665 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator, typename _Tp&gt;
<span class="lineNum">     666 </span>            :     inline _OutputIterator
<span class="lineNum">     667 </span>            :     remove_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     668 </span>            :                 _OutputIterator __result, const _Tp&amp; __value)
<span class="lineNum">     669 </span>            :     {
<span class="lineNum">     670 </span>            :       // concept requirements
<span class="lineNum">     671 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">     672 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">     673 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     674 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">     675 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type, _Tp&gt;)
<span class="lineNum">     676 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">     677 </span>            : 
<span class="lineNum">     678 </span>            :       return std::__remove_copy_if(__first, __last, __result,
<span class="lineNum">     679 </span>            :         __gnu_cxx::__ops::__iter_equals_val(__value));
<span class="lineNum">     680 </span>            :     }
<span class="lineNum">     681 </span>            : 
<span class="lineNum">     682 </span>            :   /**
<span class="lineNum">     683 </span>            :    *  @brief Copy a sequence, removing elements for which a predicate is true.
<span class="lineNum">     684 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     685 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">     686 </span>            :    *  @param  __last    An input iterator.
<span class="lineNum">     687 </span>            :    *  @param  __result  An output iterator.
<span class="lineNum">     688 </span>            :    *  @param  __pred    A predicate.
<span class="lineNum">     689 </span>            :    *  @return   An iterator designating the end of the resulting sequence.
<span class="lineNum">     690 </span>            :    *
<span class="lineNum">     691 </span>            :    *  Copies each element in the range @p [__first,__last) for which
<span class="lineNum">     692 </span>            :    *  @p __pred returns false to the range beginning at @p __result.
<span class="lineNum">     693 </span>            :    *
<span class="lineNum">     694 </span>            :    *  remove_copy_if() is stable, so the relative order of elements that are
<span class="lineNum">     695 </span>            :    *  copied is unchanged.
<span class="lineNum">     696 </span>            :   */
<span class="lineNum">     697 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">     698 </span>            :            typename _Predicate&gt;
<span class="lineNum">     699 </span>            :     inline _OutputIterator
<span class="lineNum">     700 </span>            :     remove_copy_if(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     701 </span>            :                    _OutputIterator __result, _Predicate __pred)
<span class="lineNum">     702 </span>            :     {
<span class="lineNum">     703 </span>            :       // concept requirements
<span class="lineNum">     704 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">     705 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">     706 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     707 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">     708 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     709 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">     710 </span>            : 
<span class="lineNum">     711 </span>            :       return std::__remove_copy_if(__first, __last, __result,
<span class="lineNum">     712 </span>            :                                    __gnu_cxx::__ops::__pred_iter(__pred));
<span class="lineNum">     713 </span>            :     }
<span class="lineNum">     714 </span>            : 
<span class="lineNum">     715 </span>            : #if __cplusplus &gt;= 201103L
<span class="lineNum">     716 </span>            :   /**
<span class="lineNum">     717 </span>            :    *  @brief Copy the elements of a sequence for which a predicate is true.
<span class="lineNum">     718 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     719 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">     720 </span>            :    *  @param  __last    An input iterator.
<span class="lineNum">     721 </span>            :    *  @param  __result  An output iterator.
<span class="lineNum">     722 </span>            :    *  @param  __pred    A predicate.
<span class="lineNum">     723 </span>            :    *  @return   An iterator designating the end of the resulting sequence.
<span class="lineNum">     724 </span>            :    *
<span class="lineNum">     725 </span>            :    *  Copies each element in the range @p [__first,__last) for which
<span class="lineNum">     726 </span>            :    *  @p __pred returns true to the range beginning at @p __result.
<span class="lineNum">     727 </span>            :    *
<span class="lineNum">     728 </span>            :    *  copy_if() is stable, so the relative order of elements that are
<span class="lineNum">     729 </span>            :    *  copied is unchanged.
<span class="lineNum">     730 </span>            :   */
<span class="lineNum">     731 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">     732 </span>            :            typename _Predicate&gt;
<span class="lineNum">     733 </span>            :     _OutputIterator
<span class="lineNum">     734 </span>            :     copy_if(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     735 </span>            :             _OutputIterator __result, _Predicate __pred)
<span class="lineNum">     736 </span>            :     {
<span class="lineNum">     737 </span>            :       // concept requirements
<span class="lineNum">     738 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">     739 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">     740 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     741 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">     742 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     743 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">     744 </span>            : 
<span class="lineNum">     745 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">     746 </span>            :         if (__pred(*__first))
<span class="lineNum">     747 </span>            :           {
<span class="lineNum">     748 </span>            :             *__result = *__first;
<span class="lineNum">     749 </span>            :             ++__result;
<span class="lineNum">     750 </span>            :           }
<span class="lineNum">     751 </span>            :       return __result;
<span class="lineNum">     752 </span>            :     }
<span class="lineNum">     753 </span>            : 
<span class="lineNum">     754 </span>            :   template&lt;typename _InputIterator, typename _Size, typename _OutputIterator&gt;
<span class="lineNum">     755 </span>            :     _OutputIterator
<span class="lineNum">     756 </span>            :     __copy_n(_InputIterator __first, _Size __n,
<span class="lineNum">     757 </span>            :              _OutputIterator __result, input_iterator_tag)
<span class="lineNum">     758 </span>            :     {
<span class="lineNum">     759 </span>            :       if (__n &gt; 0)
<span class="lineNum">     760 </span>            :         {
<span class="lineNum">     761 </span>            :           while (true)
<span class="lineNum">     762 </span>            :             {
<span class="lineNum">     763 </span>            :               *__result = *__first;
<span class="lineNum">     764 </span>            :               ++__result;
<span class="lineNum">     765 </span>            :               if (--__n &gt; 0)
<span class="lineNum">     766 </span>            :                 ++__first;
<span class="lineNum">     767 </span>            :               else
<span class="lineNum">     768 </span>            :                 break;
<span class="lineNum">     769 </span>            :             }
<span class="lineNum">     770 </span>            :         }
<span class="lineNum">     771 </span>            :       return __result;
<span class="lineNum">     772 </span>            :     }
<span class="lineNum">     773 </span>            : 
<span class="lineNum">     774 </span>            :   template&lt;typename _RandomAccessIterator, typename _Size,
<span class="lineNum">     775 </span>            :            typename _OutputIterator&gt;
<span class="lineNum">     776 </span>            :     inline _OutputIterator
<span class="lineNum">     777 </span>            :     __copy_n(_RandomAccessIterator __first, _Size __n,
<span class="lineNum">     778 </span>            :              _OutputIterator __result, random_access_iterator_tag)
<span class="lineNum">     779 </span>            :     { return std::copy(__first, __first + __n, __result); }
<span class="lineNum">     780 </span>            : 
<span class="lineNum">     781 </span>            :   /**
<span class="lineNum">     782 </span>            :    *  @brief Copies the range [first,first+n) into [result,result+n).
<span class="lineNum">     783 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     784 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">     785 </span>            :    *  @param  __n      The number of elements to copy.
<span class="lineNum">     786 </span>            :    *  @param  __result An output iterator.
<span class="lineNum">     787 </span>            :    *  @return  result+n.
<span class="lineNum">     788 </span>            :    *
<span class="lineNum">     789 </span>            :    *  This inline function will boil down to a call to @c memmove whenever
<span class="lineNum">     790 </span>            :    *  possible.  Failing that, if random access iterators are passed, then the
<span class="lineNum">     791 </span>            :    *  loop count will be known (and therefore a candidate for compiler
<span class="lineNum">     792 </span>            :    *  optimizations such as unrolling).
<span class="lineNum">     793 </span>            :   */
<span class="lineNum">     794 </span>            :   template&lt;typename _InputIterator, typename _Size, typename _OutputIterator&gt;
<span class="lineNum">     795 </span>            :     inline _OutputIterator
<span class="lineNum">     796 </span>            :     copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
<span class="lineNum">     797 </span>            :     {
<span class="lineNum">     798 </span>            :       // concept requirements
<span class="lineNum">     799 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">     800 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">     801 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     802 </span>            : 
<span class="lineNum">     803 </span>            :       return std::__copy_n(__first, __n, __result,
<span class="lineNum">     804 </span>            :                            std::__iterator_category(__first));
<span class="lineNum">     805 </span>            :     }
<span class="lineNum">     806 </span>            : 
<span class="lineNum">     807 </span>            :   /**
<span class="lineNum">     808 </span>            :    *  @brief Copy the elements of a sequence to separate output sequences
<span class="lineNum">     809 </span>            :    *         depending on the truth value of a predicate.
<span class="lineNum">     810 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     811 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">     812 </span>            :    *  @param  __last    An input iterator.
<span class="lineNum">     813 </span>            :    *  @param  __out_true   An output iterator.
<span class="lineNum">     814 </span>            :    *  @param  __out_false  An output iterator.
<span class="lineNum">     815 </span>            :    *  @param  __pred    A predicate.
<span class="lineNum">     816 </span>            :    *  @return   A pair designating the ends of the resulting sequences.
<span class="lineNum">     817 </span>            :    *
<span class="lineNum">     818 </span>            :    *  Copies each element in the range @p [__first,__last) for which
<span class="lineNum">     819 </span>            :    *  @p __pred returns true to the range beginning at @p out_true
<span class="lineNum">     820 </span>            :    *  and each element for which @p __pred returns false to @p __out_false.
<span class="lineNum">     821 </span>            :   */
<span class="lineNum">     822 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator1,
<span class="lineNum">     823 </span>            :            typename _OutputIterator2, typename _Predicate&gt;
<span class="lineNum">     824 </span>            :     pair&lt;_OutputIterator1, _OutputIterator2&gt;
<span class="lineNum">     825 </span>            :     partition_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">     826 </span>            :                    _OutputIterator1 __out_true, _OutputIterator2 __out_false,
<span class="lineNum">     827 </span>            :                    _Predicate __pred)
<span class="lineNum">     828 </span>            :     {
<span class="lineNum">     829 </span>            :       // concept requirements
<span class="lineNum">     830 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">     831 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator1,
<span class="lineNum">     832 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     833 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator2,
<span class="lineNum">     834 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     835 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">     836 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">     837 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">     838 </span>            :       
<span class="lineNum">     839 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">     840 </span>            :         if (__pred(*__first))
<span class="lineNum">     841 </span>            :           {
<span class="lineNum">     842 </span>            :             *__out_true = *__first;
<span class="lineNum">     843 </span>            :             ++__out_true;
<span class="lineNum">     844 </span>            :           }
<span class="lineNum">     845 </span>            :         else
<span class="lineNum">     846 </span>            :           {
<span class="lineNum">     847 </span>            :             *__out_false = *__first;
<span class="lineNum">     848 </span>            :             ++__out_false;
<span class="lineNum">     849 </span>            :           }
<span class="lineNum">     850 </span>            : 
<span class="lineNum">     851 </span>            :       return pair&lt;_OutputIterator1, _OutputIterator2&gt;(__out_true, __out_false);
<span class="lineNum">     852 </span>            :     }
<span class="lineNum">     853 </span>            : #endif
<span class="lineNum">     854 </span>            : 
<span class="lineNum">     855 </span>            :   template&lt;typename _ForwardIterator, typename _Predicate&gt;
<span class="lineNum">     856 </span>            :     _ForwardIterator
<span class="lineNum">     857 </span>            :     __remove_if(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">     858 </span>            :                 _Predicate __pred)
<span class="lineNum">     859 </span>            :     {
<span class="lineNum">     860 </span>            :       __first = std::__find_if(__first, __last, __pred);
<span class="lineNum">     861 </span>            :       if (__first == __last)
<span class="lineNum">     862 </span>            :         return __first;
<span class="lineNum">     863 </span>            :       _ForwardIterator __result = __first;
<span class="lineNum">     864 </span>            :       ++__first;
<span class="lineNum">     865 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">     866 </span>            :         if (!__pred(__first))
<span class="lineNum">     867 </span>            :           {
<span class="lineNum">     868 </span>            :             *__result = _GLIBCXX_MOVE(*__first);
<span class="lineNum">     869 </span>            :             ++__result;
<span class="lineNum">     870 </span>            :           }
<span class="lineNum">     871 </span>            :       return __result;
<span class="lineNum">     872 </span>            :     }
<span class="lineNum">     873 </span>            : 
<span class="lineNum">     874 </span>            :   /**
<span class="lineNum">     875 </span>            :    *  @brief Remove elements from a sequence.
<span class="lineNum">     876 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     877 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">     878 </span>            :    *  @param  __last   An input iterator.
<span class="lineNum">     879 </span>            :    *  @param  __value  The value to be removed.
<span class="lineNum">     880 </span>            :    *  @return   An iterator designating the end of the resulting sequence.
<span class="lineNum">     881 </span>            :    *
<span class="lineNum">     882 </span>            :    *  All elements equal to @p __value are removed from the range
<span class="lineNum">     883 </span>            :    *  @p [__first,__last).
<span class="lineNum">     884 </span>            :    *
<span class="lineNum">     885 </span>            :    *  remove() is stable, so the relative order of elements that are
<span class="lineNum">     886 </span>            :    *  not removed is unchanged.
<span class="lineNum">     887 </span>            :    *
<span class="lineNum">     888 </span>            :    *  Elements between the end of the resulting sequence and @p __last
<span class="lineNum">     889 </span>            :    *  are still present, but their value is unspecified.
<span class="lineNum">     890 </span>            :   */
<span class="lineNum">     891 </span>            :   template&lt;typename _ForwardIterator, typename _Tp&gt;
<span class="lineNum">     892 </span>            :     inline _ForwardIterator
<span class="lineNum">     893 </span>            :     remove(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">     894 </span>            :            const _Tp&amp; __value)
<span class="lineNum">     895 </span>            :     {
<span class="lineNum">     896 </span>            :       // concept requirements
<span class="lineNum">     897 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">     898 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">     899 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">     900 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type, _Tp&gt;)
<span class="lineNum">     901 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">     902 </span>            : 
<span class="lineNum">     903 </span>            :       return std::__remove_if(__first, __last,
<span class="lineNum">     904 </span>            :                 __gnu_cxx::__ops::__iter_equals_val(__value));
<span class="lineNum">     905 </span>            :     }
<span class="lineNum">     906 </span>            : 
<span class="lineNum">     907 </span>            :   /**
<span class="lineNum">     908 </span>            :    *  @brief Remove elements from a sequence using a predicate.
<span class="lineNum">     909 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     910 </span>            :    *  @param  __first  A forward iterator.
<span class="lineNum">     911 </span>            :    *  @param  __last   A forward iterator.
<span class="lineNum">     912 </span>            :    *  @param  __pred   A predicate.
<span class="lineNum">     913 </span>            :    *  @return   An iterator designating the end of the resulting sequence.
<span class="lineNum">     914 </span>            :    *
<span class="lineNum">     915 </span>            :    *  All elements for which @p __pred returns true are removed from the range
<span class="lineNum">     916 </span>            :    *  @p [__first,__last).
<span class="lineNum">     917 </span>            :    *
<span class="lineNum">     918 </span>            :    *  remove_if() is stable, so the relative order of elements that are
<span class="lineNum">     919 </span>            :    *  not removed is unchanged.
<span class="lineNum">     920 </span>            :    *
<span class="lineNum">     921 </span>            :    *  Elements between the end of the resulting sequence and @p __last
<span class="lineNum">     922 </span>            :    *  are still present, but their value is unspecified.
<span class="lineNum">     923 </span>            :   */
<span class="lineNum">     924 </span>            :   template&lt;typename _ForwardIterator, typename _Predicate&gt;
<span class="lineNum">     925 </span>            :     inline _ForwardIterator
<span class="lineNum">     926 </span>            :     remove_if(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">     927 </span>            :               _Predicate __pred)
<span class="lineNum">     928 </span>            :     {
<span class="lineNum">     929 </span>            :       // concept requirements
<span class="lineNum">     930 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">     931 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">     932 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">     933 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">     934 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">     935 </span>            : 
<span class="lineNum">     936 </span>            :       return std::__remove_if(__first, __last,
<span class="lineNum">     937 </span>            :                               __gnu_cxx::__ops::__pred_iter(__pred));
<span class="lineNum">     938 </span>            :     }
<span class="lineNum">     939 </span>            : 
<span class="lineNum">     940 </span>            :   template&lt;typename _ForwardIterator, typename _BinaryPredicate&gt;
<span class="lineNum">     941 </span>            :     _ForwardIterator
<span class="lineNum">     942 </span>            :     __adjacent_find(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">     943 </span>            :                     _BinaryPredicate __binary_pred)
<span class="lineNum">     944 </span>            :     {
<span class="lineNum">     945 </span>            :       if (__first == __last)
<span class="lineNum">     946 </span>            :         return __last;
<span class="lineNum">     947 </span>            :       _ForwardIterator __next = __first;
<span class="lineNum">     948 </span>            :       while (++__next != __last)
<span class="lineNum">     949 </span>            :         {
<span class="lineNum">     950 </span>            :           if (__binary_pred(__first, __next))
<span class="lineNum">     951 </span>            :             return __first;
<span class="lineNum">     952 </span>            :           __first = __next;
<span class="lineNum">     953 </span>            :         }
<span class="lineNum">     954 </span>            :       return __last;
<span class="lineNum">     955 </span>            :     }
<span class="lineNum">     956 </span>            : 
<span class="lineNum">     957 </span>            :   template&lt;typename _ForwardIterator, typename _BinaryPredicate&gt;
<span class="lineNum">     958 </span>            :     _ForwardIterator
<span class="lineNum">     959 </span>            :     __unique(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">     960 </span>            :              _BinaryPredicate __binary_pred)
<span class="lineNum">     961 </span>            :     {
<span class="lineNum">     962 </span>            :       // Skip the beginning, if already unique.
<span class="lineNum">     963 </span>            :       __first = std::__adjacent_find(__first, __last, __binary_pred);
<span class="lineNum">     964 </span>            :       if (__first == __last)
<span class="lineNum">     965 </span>            :         return __last;
<span class="lineNum">     966 </span>            : 
<span class="lineNum">     967 </span>            :       // Do the real copy work.
<span class="lineNum">     968 </span>            :       _ForwardIterator __dest = __first;
<span class="lineNum">     969 </span>            :       ++__first;
<span class="lineNum">     970 </span>            :       while (++__first != __last)
<span class="lineNum">     971 </span>            :         if (!__binary_pred(__dest, __first))
<span class="lineNum">     972 </span>            :           *++__dest = _GLIBCXX_MOVE(*__first);
<span class="lineNum">     973 </span>            :       return ++__dest;
<span class="lineNum">     974 </span>            :     }
<span class="lineNum">     975 </span>            : 
<span class="lineNum">     976 </span>            :   /**
<span class="lineNum">     977 </span>            :    *  @brief Remove consecutive duplicate values from a sequence.
<span class="lineNum">     978 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">     979 </span>            :    *  @param  __first  A forward iterator.
<span class="lineNum">     980 </span>            :    *  @param  __last   A forward iterator.
<span class="lineNum">     981 </span>            :    *  @return  An iterator designating the end of the resulting sequence.
<span class="lineNum">     982 </span>            :    *
<span class="lineNum">     983 </span>            :    *  Removes all but the first element from each group of consecutive
<span class="lineNum">     984 </span>            :    *  values that compare equal.
<span class="lineNum">     985 </span>            :    *  unique() is stable, so the relative order of elements that are
<span class="lineNum">     986 </span>            :    *  not removed is unchanged.
<span class="lineNum">     987 </span>            :    *  Elements between the end of the resulting sequence and @p __last
<span class="lineNum">     988 </span>            :    *  are still present, but their value is unspecified.
<span class="lineNum">     989 </span>            :   */
<span class="lineNum">     990 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">     991 </span>            :     inline _ForwardIterator
<span class="lineNum">     992 </span>            :     unique(_ForwardIterator __first, _ForwardIterator __last)
<span class="lineNum">     993 </span>            :     {
<span class="lineNum">     994 </span>            :       // concept requirements
<span class="lineNum">     995 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">     996 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">     997 </span>            :       __glibcxx_function_requires(_EqualityComparableConcept&lt;
<span class="lineNum">     998 </span>            :                      typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">     999 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    1000 </span>            : 
<span class="lineNum">    1001 </span>            :       return std::__unique(__first, __last,
<span class="lineNum">    1002 </span>            :                            __gnu_cxx::__ops::__iter_equal_to_iter());
<span class="lineNum">    1003 </span>            :     }
<span class="lineNum">    1004 </span>            : 
<span class="lineNum">    1005 </span>            :   /**
<span class="lineNum">    1006 </span>            :    *  @brief Remove consecutive values from a sequence using a predicate.
<span class="lineNum">    1007 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    1008 </span>            :    *  @param  __first        A forward iterator.
<span class="lineNum">    1009 </span>            :    *  @param  __last         A forward iterator.
<span class="lineNum">    1010 </span>            :    *  @param  __binary_pred  A binary predicate.
<span class="lineNum">    1011 </span>            :    *  @return  An iterator designating the end of the resulting sequence.
<span class="lineNum">    1012 </span>            :    *
<span class="lineNum">    1013 </span>            :    *  Removes all but the first element from each group of consecutive
<span class="lineNum">    1014 </span>            :    *  values for which @p __binary_pred returns true.
<span class="lineNum">    1015 </span>            :    *  unique() is stable, so the relative order of elements that are
<span class="lineNum">    1016 </span>            :    *  not removed is unchanged.
<span class="lineNum">    1017 </span>            :    *  Elements between the end of the resulting sequence and @p __last
<span class="lineNum">    1018 </span>            :    *  are still present, but their value is unspecified.
<span class="lineNum">    1019 </span>            :   */
<span class="lineNum">    1020 </span>            :   template&lt;typename _ForwardIterator, typename _BinaryPredicate&gt;
<span class="lineNum">    1021 </span>            :     inline _ForwardIterator
<span class="lineNum">    1022 </span>            :     unique(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    1023 </span>            :            _BinaryPredicate __binary_pred)
<span class="lineNum">    1024 </span>            :     {
<span class="lineNum">    1025 </span>            :       // concept requirements
<span class="lineNum">    1026 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">    1027 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">    1028 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    1029 </span>            :                 typename iterator_traits&lt;_ForwardIterator&gt;::value_type,
<span class="lineNum">    1030 </span>            :                 typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    1031 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    1032 </span>            : 
<span class="lineNum">    1033 </span>            :       return std::__unique(__first, __last,
<span class="lineNum">    1034 </span>            :                            __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
<span class="lineNum">    1035 </span>            :     }
<span class="lineNum">    1036 </span>            : 
<span class="lineNum">    1037 </span>            :   /**
<span class="lineNum">    1038 </span>            :    *  This is an uglified
<span class="lineNum">    1039 </span>            :    *  unique_copy(_InputIterator, _InputIterator, _OutputIterator,
<span class="lineNum">    1040 </span>            :    *              _BinaryPredicate)
<span class="lineNum">    1041 </span>            :    *  overloaded for forward iterators and output iterator as result.
<span class="lineNum">    1042 </span>            :   */
<span class="lineNum">    1043 </span>            :   template&lt;typename _ForwardIterator, typename _OutputIterator,
<span class="lineNum">    1044 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    1045 </span>            :     _OutputIterator
<span class="lineNum">    1046 </span>            :     __unique_copy(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    1047 </span>            :                   _OutputIterator __result, _BinaryPredicate __binary_pred,
<span class="lineNum">    1048 </span>            :                   forward_iterator_tag, output_iterator_tag)
<span class="lineNum">    1049 </span>            :     {
<span class="lineNum">    1050 </span>            :       // concept requirements -- iterators already checked
<span class="lineNum">    1051 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    1052 </span>            :           typename iterator_traits&lt;_ForwardIterator&gt;::value_type,
<span class="lineNum">    1053 </span>            :           typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    1054 </span>            : 
<span class="lineNum">    1055 </span>            :       _ForwardIterator __next = __first;
<span class="lineNum">    1056 </span>            :       *__result = *__first;
<span class="lineNum">    1057 </span>            :       while (++__next != __last)
<span class="lineNum">    1058 </span>            :         if (!__binary_pred(__first, __next))
<span class="lineNum">    1059 </span>            :           {
<span class="lineNum">    1060 </span>            :             __first = __next;
<span class="lineNum">    1061 </span>            :             *++__result = *__first;
<span class="lineNum">    1062 </span>            :           }
<span class="lineNum">    1063 </span>            :       return ++__result;
<span class="lineNum">    1064 </span>            :     }
<span class="lineNum">    1065 </span>            : 
<span class="lineNum">    1066 </span>            :   /**
<span class="lineNum">    1067 </span>            :    *  This is an uglified
<span class="lineNum">    1068 </span>            :    *  unique_copy(_InputIterator, _InputIterator, _OutputIterator,
<span class="lineNum">    1069 </span>            :    *              _BinaryPredicate)
<span class="lineNum">    1070 </span>            :    *  overloaded for input iterators and output iterator as result.
<span class="lineNum">    1071 </span>            :   */
<span class="lineNum">    1072 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">    1073 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    1074 </span>            :     _OutputIterator
<span class="lineNum">    1075 </span>            :     __unique_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    1076 </span>            :                   _OutputIterator __result, _BinaryPredicate __binary_pred,
<span class="lineNum">    1077 </span>            :                   input_iterator_tag, output_iterator_tag)
<span class="lineNum">    1078 </span>            :     {
<span class="lineNum">    1079 </span>            :       // concept requirements -- iterators already checked
<span class="lineNum">    1080 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    1081 </span>            :           typename iterator_traits&lt;_InputIterator&gt;::value_type,
<span class="lineNum">    1082 </span>            :           typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    1083 </span>            : 
<span class="lineNum">    1084 </span>            :       typename iterator_traits&lt;_InputIterator&gt;::value_type __value = *__first;
<span class="lineNum">    1085 </span>            :       __decltype(__gnu_cxx::__ops::__iter_comp_val(__binary_pred))
<span class="lineNum">    1086 </span>            :         __rebound_pred
<span class="lineNum">    1087 </span>            :         = __gnu_cxx::__ops::__iter_comp_val(__binary_pred);
<span class="lineNum">    1088 </span>            :       *__result = __value;
<span class="lineNum">    1089 </span>            :       while (++__first != __last)
<span class="lineNum">    1090 </span>            :         if (!__rebound_pred(__first, __value))
<span class="lineNum">    1091 </span>            :           {
<span class="lineNum">    1092 </span>            :             __value = *__first;
<span class="lineNum">    1093 </span>            :             *++__result = __value;
<span class="lineNum">    1094 </span>            :           }
<span class="lineNum">    1095 </span>            :       return ++__result;
<span class="lineNum">    1096 </span>            :     }
<span class="lineNum">    1097 </span>            : 
<span class="lineNum">    1098 </span>            :   /**
<span class="lineNum">    1099 </span>            :    *  This is an uglified
<span class="lineNum">    1100 </span>            :    *  unique_copy(_InputIterator, _InputIterator, _OutputIterator,
<span class="lineNum">    1101 </span>            :    *              _BinaryPredicate)
<span class="lineNum">    1102 </span>            :    *  overloaded for input iterators and forward iterator as result.
<span class="lineNum">    1103 </span>            :   */
<span class="lineNum">    1104 </span>            :   template&lt;typename _InputIterator, typename _ForwardIterator,
<span class="lineNum">    1105 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    1106 </span>            :     _ForwardIterator
<span class="lineNum">    1107 </span>            :     __unique_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    1108 </span>            :                   _ForwardIterator __result, _BinaryPredicate __binary_pred,
<span class="lineNum">    1109 </span>            :                   input_iterator_tag, forward_iterator_tag)
<span class="lineNum">    1110 </span>            :     {
<span class="lineNum">    1111 </span>            :       // concept requirements -- iterators already checked
<span class="lineNum">    1112 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    1113 </span>            :           typename iterator_traits&lt;_ForwardIterator&gt;::value_type,
<span class="lineNum">    1114 </span>            :           typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    1115 </span>            :       *__result = *__first;
<span class="lineNum">    1116 </span>            :       while (++__first != __last)
<span class="lineNum">    1117 </span>            :         if (!__binary_pred(__result, __first))
<span class="lineNum">    1118 </span>            :           *++__result = *__first;
<span class="lineNum">    1119 </span>            :       return ++__result;
<span class="lineNum">    1120 </span>            :     }
<span class="lineNum">    1121 </span>            : 
<span class="lineNum">    1122 </span>            :   /**
<span class="lineNum">    1123 </span>            :    *  This is an uglified reverse(_BidirectionalIterator,
<span class="lineNum">    1124 </span>            :    *                              _BidirectionalIterator)
<span class="lineNum">    1125 </span>            :    *  overloaded for bidirectional iterators.
<span class="lineNum">    1126 </span>            :   */
<span class="lineNum">    1127 </span>            :   template&lt;typename _BidirectionalIterator&gt;
<span class="lineNum">    1128 </span>            :     void
<span class="lineNum">    1129 </span>            :     __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last,
<span class="lineNum">    1130 </span>            :               bidirectional_iterator_tag)
<span class="lineNum">    1131 </span>            :     {
<span class="lineNum">    1132 </span>            :       while (true)
<span class="lineNum">    1133 </span>            :         if (__first == __last || __first == --__last)
<span class="lineNum">    1134 </span>            :           return;
<span class="lineNum">    1135 </span>            :         else
<span class="lineNum">    1136 </span>            :           {
<span class="lineNum">    1137 </span>            :             std::iter_swap(__first, __last);
<span class="lineNum">    1138 </span>            :             ++__first;
<span class="lineNum">    1139 </span>            :           }
<span class="lineNum">    1140 </span>            :     }
<span class="lineNum">    1141 </span>            : 
<span class="lineNum">    1142 </span>            :   /**
<span class="lineNum">    1143 </span>            :    *  This is an uglified reverse(_BidirectionalIterator,
<span class="lineNum">    1144 </span>            :    *                              _BidirectionalIterator)
<span class="lineNum">    1145 </span>            :    *  overloaded for random access iterators.
<span class="lineNum">    1146 </span>            :   */
<span class="lineNum">    1147 </span>            :   template&lt;typename _RandomAccessIterator&gt;
<span class="lineNum">    1148 </span>            :     void
<span class="lineNum">    1149 </span>            :     __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last,
<span class="lineNum">    1150 </span>            :               random_access_iterator_tag)
<span class="lineNum">    1151 </span>            :     {
<span class="lineNum">    1152 </span>            :       if (__first == __last)
<span class="lineNum">    1153 </span>            :         return;
<span class="lineNum">    1154 </span>            :       --__last;
<span class="lineNum">    1155 </span>            :       while (__first &lt; __last)
<span class="lineNum">    1156 </span>            :         {
<span class="lineNum">    1157 </span>            :           std::iter_swap(__first, __last);
<span class="lineNum">    1158 </span>            :           ++__first;
<span class="lineNum">    1159 </span>            :           --__last;
<span class="lineNum">    1160 </span>            :         }
<span class="lineNum">    1161 </span>            :     }
<span class="lineNum">    1162 </span>            : 
<span class="lineNum">    1163 </span>            :   /**
<span class="lineNum">    1164 </span>            :    *  @brief Reverse a sequence.
<span class="lineNum">    1165 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    1166 </span>            :    *  @param  __first  A bidirectional iterator.
<span class="lineNum">    1167 </span>            :    *  @param  __last   A bidirectional iterator.
<span class="lineNum">    1168 </span>            :    *  @return   reverse() returns no value.
<span class="lineNum">    1169 </span>            :    *
<span class="lineNum">    1170 </span>            :    *  Reverses the order of the elements in the range @p [__first,__last),
<span class="lineNum">    1171 </span>            :    *  so that the first element becomes the last etc.
<span class="lineNum">    1172 </span>            :    *  For every @c i such that @p 0&lt;=i&lt;=(__last-__first)/2), @p reverse()
<span class="lineNum">    1173 </span>            :    *  swaps @p *(__first+i) and @p *(__last-(i+1))
<span class="lineNum">    1174 </span>            :   */
<span class="lineNum">    1175 </span>            :   template&lt;typename _BidirectionalIterator&gt;
<span class="lineNum">    1176 </span>            :     inline void
<span class="lineNum">    1177 </span>            :     reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
<span class="lineNum">    1178 </span>            :     {
<span class="lineNum">    1179 </span>            :       // concept requirements
<span class="lineNum">    1180 </span>            :       __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept&lt;
<span class="lineNum">    1181 </span>            :                                   _BidirectionalIterator&gt;)
<span class="lineNum">    1182 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    1183 </span>            :       std::__reverse(__first, __last, std::__iterator_category(__first));
<span class="lineNum">    1184 </span>            :     }
<span class="lineNum">    1185 </span>            : 
<span class="lineNum">    1186 </span>            :   /**
<span class="lineNum">    1187 </span>            :    *  @brief Copy a sequence, reversing its elements.
<span class="lineNum">    1188 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    1189 </span>            :    *  @param  __first   A bidirectional iterator.
<span class="lineNum">    1190 </span>            :    *  @param  __last    A bidirectional iterator.
<span class="lineNum">    1191 </span>            :    *  @param  __result  An output iterator.
<span class="lineNum">    1192 </span>            :    *  @return  An iterator designating the end of the resulting sequence.
<span class="lineNum">    1193 </span>            :    *
<span class="lineNum">    1194 </span>            :    *  Copies the elements in the range @p [__first,__last) to the
<span class="lineNum">    1195 </span>            :    *  range @p [__result,__result+(__last-__first)) such that the
<span class="lineNum">    1196 </span>            :    *  order of the elements is reversed.  For every @c i such that @p
<span class="lineNum">    1197 </span>            :    *  0&lt;=i&lt;=(__last-__first), @p reverse_copy() performs the
<span class="lineNum">    1198 </span>            :    *  assignment @p *(__result+(__last-__first)-1-i) = *(__first+i).
<span class="lineNum">    1199 </span>            :    *  The ranges @p [__first,__last) and @p
<span class="lineNum">    1200 </span>            :    *  [__result,__result+(__last-__first)) must not overlap.
<span class="lineNum">    1201 </span>            :   */
<span class="lineNum">    1202 </span>            :   template&lt;typename _BidirectionalIterator, typename _OutputIterator&gt;
<span class="lineNum">    1203 </span>            :     _OutputIterator
<span class="lineNum">    1204 </span>            :     reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last,
<span class="lineNum">    1205 </span>            :                  _OutputIterator __result)
<span class="lineNum">    1206 </span>            :     {
<span class="lineNum">    1207 </span>            :       // concept requirements
<span class="lineNum">    1208 </span>            :       __glibcxx_function_requires(_BidirectionalIteratorConcept&lt;
<span class="lineNum">    1209 </span>            :                                   _BidirectionalIterator&gt;)
<span class="lineNum">    1210 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    1211 </span>            :                 typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type&gt;)
<span class="lineNum">    1212 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    1213 </span>            : 
<span class="lineNum">    1214 </span>            :       while (__first != __last)
<span class="lineNum">    1215 </span>            :         {
<span class="lineNum">    1216 </span>            :           --__last;
<span class="lineNum">    1217 </span>            :           *__result = *__last;
<span class="lineNum">    1218 </span>            :           ++__result;
<span class="lineNum">    1219 </span>            :         }
<span class="lineNum">    1220 </span>            :       return __result;
<span class="lineNum">    1221 </span>            :     }
<span class="lineNum">    1222 </span>            : 
<span class="lineNum">    1223 </span>            :   /**
<span class="lineNum">    1224 </span>            :    *  This is a helper function for the rotate algorithm specialized on RAIs.
<span class="lineNum">    1225 </span>            :    *  It returns the greatest common divisor of two integer values.
<span class="lineNum">    1226 </span>            :   */
<span class="lineNum">    1227 </span>            :   template&lt;typename _EuclideanRingElement&gt;
<span class="lineNum">    1228 </span>            :     _EuclideanRingElement
<span class="lineNum">    1229 </span>            :     __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
<span class="lineNum">    1230 </span>            :     {
<span class="lineNum">    1231 </span>            :       while (__n != 0)
<span class="lineNum">    1232 </span>            :         {
<span class="lineNum">    1233 </span>            :           _EuclideanRingElement __t = __m % __n;
<span class="lineNum">    1234 </span>            :           __m = __n;
<span class="lineNum">    1235 </span>            :           __n = __t;
<span class="lineNum">    1236 </span>            :         }
<span class="lineNum">    1237 </span>            :       return __m;
<span class="lineNum">    1238 </span>            :     }
<span class="lineNum">    1239 </span>            : 
<span class="lineNum">    1240 </span>            :   inline namespace _V2
<span class="lineNum">    1241 </span>            :   {
<span class="lineNum">    1242 </span>            : 
<span class="lineNum">    1243 </span>            :   /// This is a helper function for the rotate algorithm.
<span class="lineNum">    1244 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">    1245 </span>            :     _ForwardIterator
<span class="lineNum">    1246 </span>            :     __rotate(_ForwardIterator __first,
<span class="lineNum">    1247 </span>            :              _ForwardIterator __middle,
<span class="lineNum">    1248 </span>            :              _ForwardIterator __last,
<span class="lineNum">    1249 </span>            :              forward_iterator_tag)
<span class="lineNum">    1250 </span>            :     {
<span class="lineNum">    1251 </span>            :       if (__first == __middle)
<span class="lineNum">    1252 </span>            :         return __last;
<span class="lineNum">    1253 </span>            :       else if (__last  == __middle)
<span class="lineNum">    1254 </span>            :         return __first;
<span class="lineNum">    1255 </span>            : 
<span class="lineNum">    1256 </span>            :       _ForwardIterator __first2 = __middle;
<span class="lineNum">    1257 </span>            :       do
<span class="lineNum">    1258 </span>            :         {
<span class="lineNum">    1259 </span>            :           std::iter_swap(__first, __first2);
<span class="lineNum">    1260 </span>            :           ++__first;
<span class="lineNum">    1261 </span>            :           ++__first2;
<span class="lineNum">    1262 </span>            :           if (__first == __middle)
<span class="lineNum">    1263 </span>            :             __middle = __first2;
<span class="lineNum">    1264 </span>            :         }
<span class="lineNum">    1265 </span>            :       while (__first2 != __last);
<span class="lineNum">    1266 </span>            : 
<span class="lineNum">    1267 </span>            :       _ForwardIterator __ret = __first;
<span class="lineNum">    1268 </span>            : 
<span class="lineNum">    1269 </span>            :       __first2 = __middle;
<span class="lineNum">    1270 </span>            : 
<span class="lineNum">    1271 </span>            :       while (__first2 != __last)
<span class="lineNum">    1272 </span>            :         {
<span class="lineNum">    1273 </span>            :           std::iter_swap(__first, __first2);
<span class="lineNum">    1274 </span>            :           ++__first;
<span class="lineNum">    1275 </span>            :           ++__first2;
<span class="lineNum">    1276 </span>            :           if (__first == __middle)
<span class="lineNum">    1277 </span>            :             __middle = __first2;
<span class="lineNum">    1278 </span>            :           else if (__first2 == __last)
<span class="lineNum">    1279 </span>            :             __first2 = __middle;
<span class="lineNum">    1280 </span>            :         }
<span class="lineNum">    1281 </span>            :       return __ret;
<span class="lineNum">    1282 </span>            :     }
<span class="lineNum">    1283 </span>            : 
<span class="lineNum">    1284 </span>            :    /// This is a helper function for the rotate algorithm.
<span class="lineNum">    1285 </span>            :   template&lt;typename _BidirectionalIterator&gt;
<span class="lineNum">    1286 </span>            :     _BidirectionalIterator
<span class="lineNum">    1287 </span>            :     __rotate(_BidirectionalIterator __first,
<span class="lineNum">    1288 </span>            :              _BidirectionalIterator __middle,
<span class="lineNum">    1289 </span>            :              _BidirectionalIterator __last,
<span class="lineNum">    1290 </span>            :               bidirectional_iterator_tag)
<span class="lineNum">    1291 </span>            :     {
<span class="lineNum">    1292 </span>            :       // concept requirements
<span class="lineNum">    1293 </span>            :       __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept&lt;
<span class="lineNum">    1294 </span>            :                                   _BidirectionalIterator&gt;)
<span class="lineNum">    1295 </span>            : 
<span class="lineNum">    1296 </span>            :       if (__first == __middle)
<span class="lineNum">    1297 </span>            :         return __last;
<span class="lineNum">    1298 </span>            :       else if (__last  == __middle)
<span class="lineNum">    1299 </span>            :         return __first;
<span class="lineNum">    1300 </span>            : 
<span class="lineNum">    1301 </span>            :       std::__reverse(__first,  __middle, bidirectional_iterator_tag());
<span class="lineNum">    1302 </span>            :       std::__reverse(__middle, __last,   bidirectional_iterator_tag());
<span class="lineNum">    1303 </span>            : 
<span class="lineNum">    1304 </span>            :       while (__first != __middle &amp;&amp; __middle != __last)
<span class="lineNum">    1305 </span>            :         {
<span class="lineNum">    1306 </span>            :           std::iter_swap(__first, --__last);
<span class="lineNum">    1307 </span>            :           ++__first;
<span class="lineNum">    1308 </span>            :         }
<span class="lineNum">    1309 </span>            : 
<span class="lineNum">    1310 </span>            :       if (__first == __middle)
<span class="lineNum">    1311 </span>            :         {
<span class="lineNum">    1312 </span>            :           std::__reverse(__middle, __last,   bidirectional_iterator_tag());
<span class="lineNum">    1313 </span>            :           return __last;
<span class="lineNum">    1314 </span>            :         }
<span class="lineNum">    1315 </span>            :       else
<span class="lineNum">    1316 </span>            :         {
<span class="lineNum">    1317 </span>            :           std::__reverse(__first,  __middle, bidirectional_iterator_tag());
<span class="lineNum">    1318 </span>            :           return __first;
<span class="lineNum">    1319 </span>            :         }
<span class="lineNum">    1320 </span>            :     }
<span class="lineNum">    1321 </span>            : 
<span class="lineNum">    1322 </span>            :   /// This is a helper function for the rotate algorithm.
<span class="lineNum">    1323 </span>            :   template&lt;typename _RandomAccessIterator&gt;
<span class="lineNum">    1324 </span>            :     _RandomAccessIterator
<span class="lineNum">    1325 </span>            :     __rotate(_RandomAccessIterator __first,
<span class="lineNum">    1326 </span>            :              _RandomAccessIterator __middle,
<span class="lineNum">    1327 </span>            :              _RandomAccessIterator __last,
<span class="lineNum">    1328 </span>            :              random_access_iterator_tag)
<span class="lineNum">    1329 </span>            :     {
<span class="lineNum">    1330 </span>            :       // concept requirements
<span class="lineNum">    1331 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    1332 </span>            :                                   _RandomAccessIterator&gt;)
<span class="lineNum">    1333 </span>            : 
<span class="lineNum">    1334 </span>            :       if (__first == __middle)
<span class="lineNum">    1335 </span>            :         return __last;
<span class="lineNum">    1336 </span>            :       else if (__last  == __middle)
<span class="lineNum">    1337 </span>            :         return __first;
<span class="lineNum">    1338 </span>            : 
<span class="lineNum">    1339 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::difference_type
<span class="lineNum">    1340 </span>            :         _Distance;
<span class="lineNum">    1341 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type
<span class="lineNum">    1342 </span>            :         _ValueType;
<span class="lineNum">    1343 </span>            : 
<span class="lineNum">    1344 </span>            :       _Distance __n = __last   - __first;
<span class="lineNum">    1345 </span>            :       _Distance __k = __middle - __first;
<span class="lineNum">    1346 </span>            : 
<span class="lineNum">    1347 </span>            :       if (__k == __n - __k)
<span class="lineNum">    1348 </span>            :         {
<span class="lineNum">    1349 </span>            :           std::swap_ranges(__first, __middle, __middle);
<span class="lineNum">    1350 </span>            :           return __middle;
<span class="lineNum">    1351 </span>            :         }
<span class="lineNum">    1352 </span>            : 
<span class="lineNum">    1353 </span>            :       _RandomAccessIterator __p = __first;
<span class="lineNum">    1354 </span>            :       _RandomAccessIterator __ret = __first + (__last - __middle);
<span class="lineNum">    1355 </span>            : 
<span class="lineNum">    1356 </span>            :       for (;;)
<span class="lineNum">    1357 </span>            :         {
<span class="lineNum">    1358 </span>            :           if (__k &lt; __n - __k)
<span class="lineNum">    1359 </span>            :             {
<span class="lineNum">    1360 </span>            :               if (__is_pod(_ValueType) &amp;&amp; __k == 1)
<span class="lineNum">    1361 </span>            :                 {
<span class="lineNum">    1362 </span>            :                   _ValueType __t = _GLIBCXX_MOVE(*__p);
<span class="lineNum">    1363 </span>            :                   _GLIBCXX_MOVE3(__p + 1, __p + __n, __p);
<span class="lineNum">    1364 </span>            :                   *(__p + __n - 1) = _GLIBCXX_MOVE(__t);
<span class="lineNum">    1365 </span>            :                   return __ret;
<span class="lineNum">    1366 </span>            :                 }
<span class="lineNum">    1367 </span>            :               _RandomAccessIterator __q = __p + __k;
<span class="lineNum">    1368 </span>            :               for (_Distance __i = 0; __i &lt; __n - __k; ++ __i)
<span class="lineNum">    1369 </span>            :                 {
<span class="lineNum">    1370 </span>            :                   std::iter_swap(__p, __q);
<span class="lineNum">    1371 </span>            :                   ++__p;
<span class="lineNum">    1372 </span>            :                   ++__q;
<span class="lineNum">    1373 </span>            :                 }
<span class="lineNum">    1374 </span>            :               __n %= __k;
<span class="lineNum">    1375 </span>            :               if (__n == 0)
<span class="lineNum">    1376 </span>            :                 return __ret;
<span class="lineNum">    1377 </span>            :               std::swap(__n, __k);
<span class="lineNum">    1378 </span>            :               __k = __n - __k;
<span class="lineNum">    1379 </span>            :             }
<span class="lineNum">    1380 </span>            :           else
<span class="lineNum">    1381 </span>            :             {
<span class="lineNum">    1382 </span>            :               __k = __n - __k;
<span class="lineNum">    1383 </span>            :               if (__is_pod(_ValueType) &amp;&amp; __k == 1)
<span class="lineNum">    1384 </span>            :                 {
<span class="lineNum">    1385 </span>            :                   _ValueType __t = _GLIBCXX_MOVE(*(__p + __n - 1));
<span class="lineNum">    1386 </span>            :                   _GLIBCXX_MOVE_BACKWARD3(__p, __p + __n - 1, __p + __n);
<span class="lineNum">    1387 </span>            :                   *__p = _GLIBCXX_MOVE(__t);
<span class="lineNum">    1388 </span>            :                   return __ret;
<span class="lineNum">    1389 </span>            :                 }
<span class="lineNum">    1390 </span>            :               _RandomAccessIterator __q = __p + __n;
<span class="lineNum">    1391 </span>            :               __p = __q - __k;
<span class="lineNum">    1392 </span>            :               for (_Distance __i = 0; __i &lt; __n - __k; ++ __i)
<span class="lineNum">    1393 </span>            :                 {
<span class="lineNum">    1394 </span>            :                   --__p;
<span class="lineNum">    1395 </span>            :                   --__q;
<span class="lineNum">    1396 </span>            :                   std::iter_swap(__p, __q);
<span class="lineNum">    1397 </span>            :                 }
<span class="lineNum">    1398 </span>            :               __n %= __k;
<span class="lineNum">    1399 </span>            :               if (__n == 0)
<span class="lineNum">    1400 </span>            :                 return __ret;
<span class="lineNum">    1401 </span>            :               std::swap(__n, __k);
<span class="lineNum">    1402 </span>            :             }
<span class="lineNum">    1403 </span>            :         }
<span class="lineNum">    1404 </span>            :     }
<span class="lineNum">    1405 </span>            : 
<span class="lineNum">    1406 </span>            :    // _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">    1407 </span>            :    // DR 488. rotate throws away useful information
<span class="lineNum">    1408 </span>            :   /**
<span class="lineNum">    1409 </span>            :    *  @brief Rotate the elements of a sequence.
<span class="lineNum">    1410 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    1411 </span>            :    *  @param  __first   A forward iterator.
<span class="lineNum">    1412 </span>            :    *  @param  __middle  A forward iterator.
<span class="lineNum">    1413 </span>            :    *  @param  __last    A forward iterator.
<span class="lineNum">    1414 </span>            :    *  @return  first + (last - middle).
<span class="lineNum">    1415 </span>            :    *
<span class="lineNum">    1416 </span>            :    *  Rotates the elements of the range @p [__first,__last) by 
<span class="lineNum">    1417 </span>            :    *  @p (__middle - __first) positions so that the element at @p __middle
<span class="lineNum">    1418 </span>            :    *  is moved to @p __first, the element at @p __middle+1 is moved to
<span class="lineNum">    1419 </span>            :    *  @p __first+1 and so on for each element in the range
<span class="lineNum">    1420 </span>            :    *  @p [__first,__last).
<span class="lineNum">    1421 </span>            :    *
<span class="lineNum">    1422 </span>            :    *  This effectively swaps the ranges @p [__first,__middle) and
<span class="lineNum">    1423 </span>            :    *  @p [__middle,__last).
<span class="lineNum">    1424 </span>            :    *
<span class="lineNum">    1425 </span>            :    *  Performs
<span class="lineNum">    1426 </span>            :    *   @p *(__first+(n+(__last-__middle))%(__last-__first))=*(__first+n)
<span class="lineNum">    1427 </span>            :    *  for each @p n in the range @p [0,__last-__first).
<span class="lineNum">    1428 </span>            :   */
<span class="lineNum">    1429 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">    1430 </span>            :     inline _ForwardIterator
<span class="lineNum">    1431 </span>            :     rotate(_ForwardIterator __first, _ForwardIterator __middle,
<span class="lineNum">    1432 </span>            :            _ForwardIterator __last)
<span class="lineNum">    1433 </span>            :     {
<span class="lineNum">    1434 </span>            :       // concept requirements
<span class="lineNum">    1435 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">    1436 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">    1437 </span>            :       __glibcxx_requires_valid_range(__first, __middle);
<span class="lineNum">    1438 </span>            :       __glibcxx_requires_valid_range(__middle, __last);
<span class="lineNum">    1439 </span>            : 
<span class="lineNum">    1440 </span>            :       return std::__rotate(__first, __middle, __last,
<span class="lineNum">    1441 </span>            :                            std::__iterator_category(__first));
<span class="lineNum">    1442 </span>            :     }
<span class="lineNum">    1443 </span>            : 
<span class="lineNum">    1444 </span>            :   } // namespace _V2
<span class="lineNum">    1445 </span>            : 
<span class="lineNum">    1446 </span>            :   /**
<span class="lineNum">    1447 </span>            :    *  @brief Copy a sequence, rotating its elements.
<span class="lineNum">    1448 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    1449 </span>            :    *  @param  __first   A forward iterator.
<span class="lineNum">    1450 </span>            :    *  @param  __middle  A forward iterator.
<span class="lineNum">    1451 </span>            :    *  @param  __last    A forward iterator.
<span class="lineNum">    1452 </span>            :    *  @param  __result  An output iterator.
<span class="lineNum">    1453 </span>            :    *  @return   An iterator designating the end of the resulting sequence.
<span class="lineNum">    1454 </span>            :    *
<span class="lineNum">    1455 </span>            :    *  Copies the elements of the range @p [__first,__last) to the
<span class="lineNum">    1456 </span>            :    *  range beginning at @result, rotating the copied elements by 
<span class="lineNum">    1457 </span>            :    *  @p (__middle-__first) positions so that the element at @p __middle
<span class="lineNum">    1458 </span>            :    *  is moved to @p __result, the element at @p __middle+1 is moved
<span class="lineNum">    1459 </span>            :    *  to @p __result+1 and so on for each element in the range @p
<span class="lineNum">    1460 </span>            :    *  [__first,__last).
<span class="lineNum">    1461 </span>            :    *
<span class="lineNum">    1462 </span>            :    *  Performs 
<span class="lineNum">    1463 </span>            :    *  @p *(__result+(n+(__last-__middle))%(__last-__first))=*(__first+n)
<span class="lineNum">    1464 </span>            :    *  for each @p n in the range @p [0,__last-__first).
<span class="lineNum">    1465 </span>            :   */
<span class="lineNum">    1466 </span>            :   template&lt;typename _ForwardIterator, typename _OutputIterator&gt;
<span class="lineNum">    1467 </span>            :     inline _OutputIterator
<span class="lineNum">    1468 </span>            :     rotate_copy(_ForwardIterator __first, _ForwardIterator __middle,
<span class="lineNum">    1469 </span>            :                 _ForwardIterator __last, _OutputIterator __result)
<span class="lineNum">    1470 </span>            :     {
<span class="lineNum">    1471 </span>            :       // concept requirements
<span class="lineNum">    1472 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    1473 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    1474 </span>            :                 typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    1475 </span>            :       __glibcxx_requires_valid_range(__first, __middle);
<span class="lineNum">    1476 </span>            :       __glibcxx_requires_valid_range(__middle, __last);
<span class="lineNum">    1477 </span>            : 
<span class="lineNum">    1478 </span>            :       return std::copy(__first, __middle,
<span class="lineNum">    1479 </span>            :                        std::copy(__middle, __last, __result));
<span class="lineNum">    1480 </span>            :     }
<span class="lineNum">    1481 </span>            : 
<span class="lineNum">    1482 </span>            :   /// This is a helper function...
<span class="lineNum">    1483 </span>            :   template&lt;typename _ForwardIterator, typename _Predicate&gt;
<span class="lineNum">    1484 </span>            :     _ForwardIterator
<span class="lineNum">    1485 </span>            :     __partition(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    1486 </span>            :                 _Predicate __pred, forward_iterator_tag)
<span class="lineNum">    1487 </span>            :     {
<span class="lineNum">    1488 </span>            :       if (__first == __last)
<span class="lineNum">    1489 </span>            :         return __first;
<span class="lineNum">    1490 </span>            : 
<span class="lineNum">    1491 </span>            :       while (__pred(*__first))
<span class="lineNum">    1492 </span>            :         if (++__first == __last)
<span class="lineNum">    1493 </span>            :           return __first;
<span class="lineNum">    1494 </span>            : 
<span class="lineNum">    1495 </span>            :       _ForwardIterator __next = __first;
<span class="lineNum">    1496 </span>            : 
<span class="lineNum">    1497 </span>            :       while (++__next != __last)
<span class="lineNum">    1498 </span>            :         if (__pred(*__next))
<span class="lineNum">    1499 </span>            :           {
<span class="lineNum">    1500 </span>            :             std::iter_swap(__first, __next);
<span class="lineNum">    1501 </span>            :             ++__first;
<span class="lineNum">    1502 </span>            :           }
<span class="lineNum">    1503 </span>            : 
<span class="lineNum">    1504 </span>            :       return __first;
<span class="lineNum">    1505 </span>            :     }
<span class="lineNum">    1506 </span>            : 
<span class="lineNum">    1507 </span>            :   /// This is a helper function...
<span class="lineNum">    1508 </span>            :   template&lt;typename _BidirectionalIterator, typename _Predicate&gt;
<span class="lineNum">    1509 </span>            :     _BidirectionalIterator
<span class="lineNum">    1510 </span>            :     __partition(_BidirectionalIterator __first, _BidirectionalIterator __last,
<span class="lineNum">    1511 </span>            :                 _Predicate __pred, bidirectional_iterator_tag)
<span class="lineNum">    1512 </span>            :     {
<span class="lineNum">    1513 </span>            :       while (true)
<span class="lineNum">    1514 </span>            :         {
<span class="lineNum">    1515 </span>            :           while (true)
<span class="lineNum">    1516 </span>            :             if (__first == __last)
<span class="lineNum">    1517 </span>            :               return __first;
<span class="lineNum">    1518 </span>            :             else if (__pred(*__first))
<span class="lineNum">    1519 </span>            :               ++__first;
<span class="lineNum">    1520 </span>            :             else
<span class="lineNum">    1521 </span>            :               break;
<span class="lineNum">    1522 </span>            :           --__last;
<span class="lineNum">    1523 </span>            :           while (true)
<span class="lineNum">    1524 </span>            :             if (__first == __last)
<span class="lineNum">    1525 </span>            :               return __first;
<span class="lineNum">    1526 </span>            :             else if (!bool(__pred(*__last)))
<span class="lineNum">    1527 </span>            :               --__last;
<span class="lineNum">    1528 </span>            :             else
<span class="lineNum">    1529 </span>            :               break;
<span class="lineNum">    1530 </span>            :           std::iter_swap(__first, __last);
<span class="lineNum">    1531 </span>            :           ++__first;
<span class="lineNum">    1532 </span>            :         }
<span class="lineNum">    1533 </span>            :     }
<span class="lineNum">    1534 </span>            : 
<span class="lineNum">    1535 </span>            :   // partition
<span class="lineNum">    1536 </span>            : 
<span class="lineNum">    1537 </span>            :   /// This is a helper function...
<span class="lineNum">    1538 </span>            :   /// Requires __first != __last and !__pred(__first)
<span class="lineNum">    1539 </span>            :   /// and __len == distance(__first, __last).
<span class="lineNum">    1540 </span>            :   ///
<span class="lineNum">    1541 </span>            :   /// !__pred(__first) allows us to guarantee that we don't
<span class="lineNum">    1542 </span>            :   /// move-assign an element onto itself.
<span class="lineNum">    1543 </span>            :   template&lt;typename _ForwardIterator, typename _Pointer, typename _Predicate,
<span class="lineNum">    1544 </span>            :            typename _Distance&gt;
<span class="lineNum">    1545 </span>            :     _ForwardIterator
<span class="lineNum">    1546 </span>            :     __stable_partition_adaptive(_ForwardIterator __first,
<span class="lineNum">    1547 </span>            :                                 _ForwardIterator __last,
<span class="lineNum">    1548 </span>            :                                 _Predicate __pred, _Distance __len,
<span class="lineNum">    1549 </span>            :                                 _Pointer __buffer,
<span class="lineNum">    1550 </span>            :                                 _Distance __buffer_size)
<span class="lineNum">    1551 </span>            :     {
<span class="lineNum">    1552 </span>            :       if (__len == 1)
<span class="lineNum">    1553 </span>            :         return __first;
<span class="lineNum">    1554 </span>            : 
<span class="lineNum">    1555 </span>            :       if (__len &lt;= __buffer_size)
<span class="lineNum">    1556 </span>            :         {
<span class="lineNum">    1557 </span>            :           _ForwardIterator __result1 = __first;
<span class="lineNum">    1558 </span>            :           _Pointer __result2 = __buffer;
<span class="lineNum">    1559 </span>            : 
<span class="lineNum">    1560 </span>            :           // The precondition guarantees that !__pred(__first), so
<span class="lineNum">    1561 </span>            :           // move that element to the buffer before starting the loop.
<span class="lineNum">    1562 </span>            :           // This ensures that we only call __pred once per element.
<span class="lineNum">    1563 </span>            :           *__result2 = _GLIBCXX_MOVE(*__first);
<span class="lineNum">    1564 </span>            :           ++__result2;
<span class="lineNum">    1565 </span>            :           ++__first;
<span class="lineNum">    1566 </span>            :           for (; __first != __last; ++__first)
<span class="lineNum">    1567 </span>            :             if (__pred(__first))
<span class="lineNum">    1568 </span>            :               {
<span class="lineNum">    1569 </span>            :                 *__result1 = _GLIBCXX_MOVE(*__first);
<span class="lineNum">    1570 </span>            :                 ++__result1;
<span class="lineNum">    1571 </span>            :               }
<span class="lineNum">    1572 </span>            :             else
<span class="lineNum">    1573 </span>            :               {
<span class="lineNum">    1574 </span>            :                 *__result2 = _GLIBCXX_MOVE(*__first);
<span class="lineNum">    1575 </span>            :                 ++__result2;
<span class="lineNum">    1576 </span>            :               }
<span class="lineNum">    1577 </span>            : 
<span class="lineNum">    1578 </span>            :           _GLIBCXX_MOVE3(__buffer, __result2, __result1);
<span class="lineNum">    1579 </span>            :           return __result1;
<span class="lineNum">    1580 </span>            :         }
<span class="lineNum">    1581 </span>            : 
<span class="lineNum">    1582 </span>            :       _ForwardIterator __middle = __first;
<span class="lineNum">    1583 </span>            :       std::advance(__middle, __len / 2);
<span class="lineNum">    1584 </span>            :       _ForwardIterator __left_split =
<span class="lineNum">    1585 </span>            :         std::__stable_partition_adaptive(__first, __middle, __pred,
<span class="lineNum">    1586 </span>            :                                          __len / 2, __buffer,
<span class="lineNum">    1587 </span>            :                                          __buffer_size);
<span class="lineNum">    1588 </span>            : 
<span class="lineNum">    1589 </span>            :       // Advance past true-predicate values to satisfy this
<span class="lineNum">    1590 </span>            :       // function's preconditions.
<span class="lineNum">    1591 </span>            :       _Distance __right_len = __len - __len / 2;
<span class="lineNum">    1592 </span>            :       _ForwardIterator __right_split =
<span class="lineNum">    1593 </span>            :         std::__find_if_not_n(__middle, __right_len, __pred);
<span class="lineNum">    1594 </span>            : 
<span class="lineNum">    1595 </span>            :       if (__right_len)
<span class="lineNum">    1596 </span>            :         __right_split =
<span class="lineNum">    1597 </span>            :           std::__stable_partition_adaptive(__right_split, __last, __pred,
<span class="lineNum">    1598 </span>            :                                            __right_len,
<span class="lineNum">    1599 </span>            :                                            __buffer, __buffer_size);
<span class="lineNum">    1600 </span>            : 
<span class="lineNum">    1601 </span>            :       std::rotate(__left_split, __middle, __right_split);
<span class="lineNum">    1602 </span>            :       std::advance(__left_split, std::distance(__middle, __right_split));
<span class="lineNum">    1603 </span>            :       return __left_split;
<span class="lineNum">    1604 </span>            :     }
<span class="lineNum">    1605 </span>            : 
<span class="lineNum">    1606 </span>            :   template&lt;typename _ForwardIterator, typename _Predicate&gt;
<span class="lineNum">    1607 </span>            :     _ForwardIterator
<span class="lineNum">    1608 </span>            :     __stable_partition(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    1609 </span>            :                        _Predicate __pred)
<span class="lineNum">    1610 </span>            :     {
<span class="lineNum">    1611 </span>            :       __first = std::__find_if_not(__first, __last, __pred);
<span class="lineNum">    1612 </span>            : 
<span class="lineNum">    1613 </span>            :       if (__first == __last)
<span class="lineNum">    1614 </span>            :         return __first;
<span class="lineNum">    1615 </span>            : 
<span class="lineNum">    1616 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    1617 </span>            :         _ValueType;
<span class="lineNum">    1618 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::difference_type
<span class="lineNum">    1619 </span>            :         _DistanceType;
<span class="lineNum">    1620 </span>            : 
<span class="lineNum">    1621 </span>            :       _Temporary_buffer&lt;_ForwardIterator, _ValueType&gt; __buf(__first, __last);
<span class="lineNum">    1622 </span>            :       return
<span class="lineNum">    1623 </span>            :         std::__stable_partition_adaptive(__first, __last, __pred,
<span class="lineNum">    1624 </span>            :                                          _DistanceType(__buf.requested_size()),
<span class="lineNum">    1625 </span>            :                                          __buf.begin(),
<span class="lineNum">    1626 </span>            :                                          _DistanceType(__buf.size()));
<span class="lineNum">    1627 </span>            :     }
<span class="lineNum">    1628 </span>            : 
<span class="lineNum">    1629 </span>            :   /**
<span class="lineNum">    1630 </span>            :    *  @brief Move elements for which a predicate is true to the beginning
<span class="lineNum">    1631 </span>            :    *         of a sequence, preserving relative ordering.
<span class="lineNum">    1632 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    1633 </span>            :    *  @param  __first   A forward iterator.
<span class="lineNum">    1634 </span>            :    *  @param  __last    A forward iterator.
<span class="lineNum">    1635 </span>            :    *  @param  __pred    A predicate functor.
<span class="lineNum">    1636 </span>            :    *  @return  An iterator @p middle such that @p __pred(i) is true for each
<span class="lineNum">    1637 </span>            :    *  iterator @p i in the range @p [first,middle) and false for each @p i
<span class="lineNum">    1638 </span>            :    *  in the range @p [middle,last).
<span class="lineNum">    1639 </span>            :    *
<span class="lineNum">    1640 </span>            :    *  Performs the same function as @p partition() with the additional
<span class="lineNum">    1641 </span>            :    *  guarantee that the relative ordering of elements in each group is
<span class="lineNum">    1642 </span>            :    *  preserved, so any two elements @p x and @p y in the range
<span class="lineNum">    1643 </span>            :    *  @p [__first,__last) such that @p __pred(x)==__pred(y) will have the same
<span class="lineNum">    1644 </span>            :    *  relative ordering after calling @p stable_partition().
<span class="lineNum">    1645 </span>            :   */
<span class="lineNum">    1646 </span>            :   template&lt;typename _ForwardIterator, typename _Predicate&gt;
<span class="lineNum">    1647 </span>            :     inline _ForwardIterator
<span class="lineNum">    1648 </span>            :     stable_partition(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    1649 </span>            :                      _Predicate __pred)
<span class="lineNum">    1650 </span>            :     {
<span class="lineNum">    1651 </span>            :       // concept requirements
<span class="lineNum">    1652 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">    1653 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">    1654 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">    1655 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    1656 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    1657 </span>            : 
<span class="lineNum">    1658 </span>            :       return std::__stable_partition(__first, __last,
<span class="lineNum">    1659 </span>            :                                      __gnu_cxx::__ops::__pred_iter(__pred));
<span class="lineNum">    1660 </span>            :     }
<span class="lineNum">    1661 </span>            : 
<span class="lineNum">    1662 </span>            :   /// This is a helper function for the sort routines.
<a name="1663"><span class="lineNum">    1663 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;</a>
<span class="lineNum">    1664 </span>            :     void
<span class="lineNum">    1665 </span><span class="lineNoCov">          0 :     __heap_select(_RandomAccessIterator __first,</span>
<span class="lineNum">    1666 </span>            :                   _RandomAccessIterator __middle,
<span class="lineNum">    1667 </span>            :                   _RandomAccessIterator __last, _Compare __comp)
<span class="lineNum">    1668 </span>            :     {
<span class="lineNum">    1669 </span><span class="lineNoCov">          0 :       std::__make_heap(__first, __middle, __comp);</span>
<span class="lineNum">    1670 </span><span class="lineNoCov">          0 :       for (_RandomAccessIterator __i = __middle; __i &lt; __last; ++__i)</span>
<span class="lineNum">    1671 </span><span class="lineNoCov">          0 :         if (__comp(__i, __first))</span>
<span class="lineNum">    1672 </span><span class="lineNoCov">          0 :           std::__pop_heap(__first, __middle, __i, __comp);</span>
<span class="lineNum">    1673 </span><span class="lineNoCov">          0 :     }</span>
<span class="lineNum">    1674 </span>            : 
<span class="lineNum">    1675 </span>            :   // partial_sort
<span class="lineNum">    1676 </span>            : 
<span class="lineNum">    1677 </span>            :   template&lt;typename _InputIterator, typename _RandomAccessIterator,
<span class="lineNum">    1678 </span>            :            typename _Compare&gt;
<span class="lineNum">    1679 </span>            :     _RandomAccessIterator
<span class="lineNum">    1680 </span>            :     __partial_sort_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    1681 </span>            :                         _RandomAccessIterator __result_first,
<span class="lineNum">    1682 </span>            :                         _RandomAccessIterator __result_last,
<span class="lineNum">    1683 </span>            :                         _Compare __comp)
<span class="lineNum">    1684 </span>            :     {
<span class="lineNum">    1685 </span>            :       typedef typename iterator_traits&lt;_InputIterator&gt;::value_type
<span class="lineNum">    1686 </span>            :         _InputValueType;
<span class="lineNum">    1687 </span>            :       typedef iterator_traits&lt;_RandomAccessIterator&gt; _RItTraits;
<span class="lineNum">    1688 </span>            :       typedef typename _RItTraits::difference_type _DistanceType;
<span class="lineNum">    1689 </span>            : 
<span class="lineNum">    1690 </span>            :       if (__result_first == __result_last)
<span class="lineNum">    1691 </span>            :         return __result_last;
<span class="lineNum">    1692 </span>            :       _RandomAccessIterator __result_real_last = __result_first;
<span class="lineNum">    1693 </span>            :       while (__first != __last &amp;&amp; __result_real_last != __result_last)
<span class="lineNum">    1694 </span>            :         {
<span class="lineNum">    1695 </span>            :           *__result_real_last = *__first;
<span class="lineNum">    1696 </span>            :           ++__result_real_last;
<span class="lineNum">    1697 </span>            :           ++__first;
<span class="lineNum">    1698 </span>            :         }
<span class="lineNum">    1699 </span>            :       
<span class="lineNum">    1700 </span>            :       std::__make_heap(__result_first, __result_real_last, __comp);
<span class="lineNum">    1701 </span>            :       while (__first != __last)
<span class="lineNum">    1702 </span>            :         {
<span class="lineNum">    1703 </span>            :           if (__comp(__first, __result_first))
<span class="lineNum">    1704 </span>            :             std::__adjust_heap(__result_first, _DistanceType(0),
<span class="lineNum">    1705 </span>            :                                _DistanceType(__result_real_last
<span class="lineNum">    1706 </span>            :                                              - __result_first),
<span class="lineNum">    1707 </span>            :                                _InputValueType(*__first), __comp);
<span class="lineNum">    1708 </span>            :           ++__first;
<span class="lineNum">    1709 </span>            :         }
<span class="lineNum">    1710 </span>            :       std::__sort_heap(__result_first, __result_real_last, __comp);
<span class="lineNum">    1711 </span>            :       return __result_real_last;
<span class="lineNum">    1712 </span>            :     }
<span class="lineNum">    1713 </span>            : 
<span class="lineNum">    1714 </span>            :   /**
<span class="lineNum">    1715 </span>            :    *  @brief Copy the smallest elements of a sequence.
<span class="lineNum">    1716 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    1717 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    1718 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    1719 </span>            :    *  @param  __result_first   A random-access iterator.
<span class="lineNum">    1720 </span>            :    *  @param  __result_last    Another random-access iterator.
<span class="lineNum">    1721 </span>            :    *  @return   An iterator indicating the end of the resulting sequence.
<span class="lineNum">    1722 </span>            :    *
<span class="lineNum">    1723 </span>            :    *  Copies and sorts the smallest N values from the range @p [__first,__last)
<span class="lineNum">    1724 </span>            :    *  to the range beginning at @p __result_first, where the number of
<span class="lineNum">    1725 </span>            :    *  elements to be copied, @p N, is the smaller of @p (__last-__first) and
<span class="lineNum">    1726 </span>            :    *  @p (__result_last-__result_first).
<span class="lineNum">    1727 </span>            :    *  After the sort if @e i and @e j are iterators in the range
<span class="lineNum">    1728 </span>            :    *  @p [__result_first,__result_first+N) such that i precedes j then
<span class="lineNum">    1729 </span>            :    *  *j&lt;*i is false.
<span class="lineNum">    1730 </span>            :    *  The value returned is @p __result_first+N.
<span class="lineNum">    1731 </span>            :   */
<span class="lineNum">    1732 </span>            :   template&lt;typename _InputIterator, typename _RandomAccessIterator&gt;
<span class="lineNum">    1733 </span>            :     inline _RandomAccessIterator
<span class="lineNum">    1734 </span>            :     partial_sort_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    1735 </span>            :                       _RandomAccessIterator __result_first,
<span class="lineNum">    1736 </span>            :                       _RandomAccessIterator __result_last)
<span class="lineNum">    1737 </span>            :     {
<span class="lineNum">    1738 </span>            :       typedef typename iterator_traits&lt;_InputIterator&gt;::value_type
<span class="lineNum">    1739 </span>            :         _InputValueType;
<span class="lineNum">    1740 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type
<span class="lineNum">    1741 </span>            :         _OutputValueType;
<span class="lineNum">    1742 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::difference_type
<span class="lineNum">    1743 </span>            :         _DistanceType;
<span class="lineNum">    1744 </span>            : 
<span class="lineNum">    1745 </span>            :       // concept requirements
<span class="lineNum">    1746 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    1747 </span>            :       __glibcxx_function_requires(_ConvertibleConcept&lt;_InputValueType,
<span class="lineNum">    1748 </span>            :                                   _OutputValueType&gt;)
<span class="lineNum">    1749 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;_InputValueType,
<span class="lineNum">    1750 </span>            :                                                      _OutputValueType&gt;)
<span class="lineNum">    1751 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;_OutputValueType&gt;)
<span class="lineNum">    1752 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    1753 </span>            :       __glibcxx_requires_valid_range(__result_first, __result_last);
<span class="lineNum">    1754 </span>            : 
<span class="lineNum">    1755 </span>            :       return std::__partial_sort_copy(__first, __last,
<span class="lineNum">    1756 </span>            :                                       __result_first, __result_last,
<span class="lineNum">    1757 </span>            :                                       __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    1758 </span>            :     }
<span class="lineNum">    1759 </span>            : 
<span class="lineNum">    1760 </span>            :   /**
<span class="lineNum">    1761 </span>            :    *  @brief Copy the smallest elements of a sequence using a predicate for
<span class="lineNum">    1762 </span>            :    *         comparison.
<span class="lineNum">    1763 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    1764 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">    1765 </span>            :    *  @param  __last    Another input iterator.
<span class="lineNum">    1766 </span>            :    *  @param  __result_first   A random-access iterator.
<span class="lineNum">    1767 </span>            :    *  @param  __result_last    Another random-access iterator.
<span class="lineNum">    1768 </span>            :    *  @param  __comp    A comparison functor.
<span class="lineNum">    1769 </span>            :    *  @return   An iterator indicating the end of the resulting sequence.
<span class="lineNum">    1770 </span>            :    *
<span class="lineNum">    1771 </span>            :    *  Copies and sorts the smallest N values from the range @p [__first,__last)
<span class="lineNum">    1772 </span>            :    *  to the range beginning at @p result_first, where the number of
<span class="lineNum">    1773 </span>            :    *  elements to be copied, @p N, is the smaller of @p (__last-__first) and
<span class="lineNum">    1774 </span>            :    *  @p (__result_last-__result_first).
<span class="lineNum">    1775 </span>            :    *  After the sort if @e i and @e j are iterators in the range
<span class="lineNum">    1776 </span>            :    *  @p [__result_first,__result_first+N) such that i precedes j then
<span class="lineNum">    1777 </span>            :    *  @p __comp(*j,*i) is false.
<span class="lineNum">    1778 </span>            :    *  The value returned is @p __result_first+N.
<span class="lineNum">    1779 </span>            :   */
<span class="lineNum">    1780 </span>            :   template&lt;typename _InputIterator, typename _RandomAccessIterator,
<span class="lineNum">    1781 </span>            :            typename _Compare&gt;
<span class="lineNum">    1782 </span>            :     inline _RandomAccessIterator
<span class="lineNum">    1783 </span>            :     partial_sort_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    1784 </span>            :                       _RandomAccessIterator __result_first,
<span class="lineNum">    1785 </span>            :                       _RandomAccessIterator __result_last,
<span class="lineNum">    1786 </span>            :                       _Compare __comp)
<span class="lineNum">    1787 </span>            :     {
<span class="lineNum">    1788 </span>            :       typedef typename iterator_traits&lt;_InputIterator&gt;::value_type
<span class="lineNum">    1789 </span>            :         _InputValueType;
<span class="lineNum">    1790 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type
<span class="lineNum">    1791 </span>            :         _OutputValueType;
<span class="lineNum">    1792 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::difference_type
<span class="lineNum">    1793 </span>            :         _DistanceType;
<span class="lineNum">    1794 </span>            : 
<span class="lineNum">    1795 </span>            :       // concept requirements
<span class="lineNum">    1796 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    1797 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    1798 </span>            :                                   _RandomAccessIterator&gt;)
<span class="lineNum">    1799 </span>            :       __glibcxx_function_requires(_ConvertibleConcept&lt;_InputValueType,
<span class="lineNum">    1800 </span>            :                                   _OutputValueType&gt;)
<span class="lineNum">    1801 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    1802 </span>            :                                   _InputValueType, _OutputValueType&gt;)
<span class="lineNum">    1803 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    1804 </span>            :                                   _OutputValueType, _OutputValueType&gt;)
<span class="lineNum">    1805 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    1806 </span>            :       __glibcxx_requires_valid_range(__result_first, __result_last);
<span class="lineNum">    1807 </span>            : 
<span class="lineNum">    1808 </span>            :       return std::__partial_sort_copy(__first, __last,
<span class="lineNum">    1809 </span>            :                                       __result_first, __result_last,
<span class="lineNum">    1810 </span>            :                                 __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    1811 </span>            :     }
<span class="lineNum">    1812 </span>            : 
<span class="lineNum">    1813 </span>            :   /// This is a helper function for the sort routine.
<span class="lineNum">    1814 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;
<span class="lineNum">    1815 </span>            :     void
<span class="lineNum">    1816 </span>            :     __unguarded_linear_insert(_RandomAccessIterator __last,
<span class="lineNum">    1817 </span>            :                               _Compare __comp)
<span class="lineNum">    1818 </span>            :     {
<span class="lineNum">    1819 </span>            :       typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type
<span class="lineNum">    1820 </span><span class="lineNoCov">          0 :         __val = _GLIBCXX_MOVE(*__last);</span>
<span class="lineNum">    1821 </span>            :       _RandomAccessIterator __next = __last;
<span class="lineNum">    1822 </span><span class="lineNoCov">          0 :       --__next;</span>
<span class="lineNum">    1823 </span><span class="lineNoCov">          0 :       while (__comp(__val, __next))</span>
<span class="lineNum">    1824 </span>            :         {
<span class="lineNum">    1825 </span><span class="lineNoCov">          0 :           *__last = _GLIBCXX_MOVE(*__next);</span>
<span class="lineNum">    1826 </span>            :           __last = __next;
<span class="lineNum">    1827 </span><span class="lineNoCov">          0 :           --__next;</span>
<span class="lineNum">    1828 </span>            :         }
<span class="lineNum">    1829 </span><span class="lineNoCov">          0 :       *__last = _GLIBCXX_MOVE(__val);</span>
<span class="lineNum">    1830 </span>            :     }
<span class="lineNum">    1831 </span>            : 
<span class="lineNum">    1832 </span>            :   /// This is a helper function for the sort routine.
<a name="1833"><span class="lineNum">    1833 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;</a>
<span class="lineNum">    1834 </span>            :     void
<span class="lineNum">    1835 </span><span class="lineCov">          1 :     __insertion_sort(_RandomAccessIterator __first,</span>
<span class="lineNum">    1836 </span>            :                      _RandomAccessIterator __last, _Compare __comp)
<span class="lineNum">    1837 </span>            :     {
<span class="lineNum">    1838 </span><span class="lineCov">          1 :       if (__first == __last) return;</span>
<span class="lineNum">    1839 </span>            : 
<span class="lineNum">    1840 </span><span class="lineCov">          1 :       for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)</span>
<span class="lineNum">    1841 </span>            :         {
<span class="lineNum">    1842 </span><span class="lineNoCov">          0 :           if (__comp(__i, __first))</span>
<span class="lineNum">    1843 </span>            :             {
<span class="lineNum">    1844 </span>            :               typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type
<span class="lineNum">    1845 </span>            :                 __val = _GLIBCXX_MOVE(*__i);
<span class="lineNum">    1846 </span><span class="lineNoCov">          0 :               _GLIBCXX_MOVE_BACKWARD3(__first, __i, __i + 1);</span>
<span class="lineNum">    1847 </span><span class="lineNoCov">          0 :               *__first = _GLIBCXX_MOVE(__val);</span>
<span class="lineNum">    1848 </span>            :             }
<span class="lineNum">    1849 </span>            :           else
<span class="lineNum">    1850 </span>            :             std::__unguarded_linear_insert(__i,
<span class="lineNum">    1851 </span>            :                                 __gnu_cxx::__ops::__val_comp_iter(__comp));
<span class="lineNum">    1852 </span>            :         }
<span class="lineNum">    1853 </span>            :     }
<span class="lineNum">    1854 </span>            : 
<span class="lineNum">    1855 </span>            :   /// This is a helper function for the sort routine.
<span class="lineNum">    1856 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;
<span class="lineNum">    1857 </span>            :     inline void
<span class="lineNum">    1858 </span>            :     __unguarded_insertion_sort(_RandomAccessIterator __first,
<span class="lineNum">    1859 </span>            :                                _RandomAccessIterator __last, _Compare __comp)
<span class="lineNum">    1860 </span>            :     {
<span class="lineNum">    1861 </span><span class="lineNoCov">          0 :       for (_RandomAccessIterator __i = __first; __i != __last; ++__i)</span>
<span class="lineNum">    1862 </span>            :         std::__unguarded_linear_insert(__i,
<span class="lineNum">    1863 </span>            :                                 __gnu_cxx::__ops::__val_comp_iter(__comp));
<span class="lineNum">    1864 </span>            :     }
<span class="lineNum">    1865 </span>            : 
<span class="lineNum">    1866 </span>            :   /**
<span class="lineNum">    1867 </span>            :    *  @doctodo
<span class="lineNum">    1868 </span>            :    *  This controls some aspect of the sort routines.
<span class="lineNum">    1869 </span>            :   */
<span class="lineNum">    1870 </span>            :   enum { _S_threshold = 16 };
<span class="lineNum">    1871 </span>            : 
<span class="lineNum">    1872 </span>            :   /// This is a helper function for the sort routine.
<a name="1873"><span class="lineNum">    1873 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;</a>
<span class="lineNum">    1874 </span>            :     void
<span class="lineNum">    1875 </span><span class="lineCov">          1 :     __final_insertion_sort(_RandomAccessIterator __first,</span>
<span class="lineNum">    1876 </span>            :                            _RandomAccessIterator __last, _Compare __comp)
<span class="lineNum">    1877 </span>            :     {
<span class="lineNum">    1878 </span><span class="lineCov">          1 :       if (__last - __first &gt; int(_S_threshold))</span>
<span class="lineNum">    1879 </span>            :         {
<span class="lineNum">    1880 </span><span class="lineNoCov">          0 :           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);</span>
<span class="lineNum">    1881 </span>            :           std::__unguarded_insertion_sort(__first + int(_S_threshold), __last,
<span class="lineNum">    1882 </span>            :                                           __comp);
<span class="lineNum">    1883 </span>            :         }
<span class="lineNum">    1884 </span>            :       else
<span class="lineNum">    1885 </span><span class="lineCov">          1 :         std::__insertion_sort(__first, __last, __comp);</span>
<span class="lineNum">    1886 </span><span class="lineCov">          1 :     }</span>
<span class="lineNum">    1887 </span>            : 
<span class="lineNum">    1888 </span>            :   /// This is a helper function...
<span class="lineNum">    1889 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;
<span class="lineNum">    1890 </span>            :     _RandomAccessIterator
<span class="lineNum">    1891 </span>            :     __unguarded_partition(_RandomAccessIterator __first,
<span class="lineNum">    1892 </span>            :                           _RandomAccessIterator __last,
<span class="lineNum">    1893 </span>            :                           _RandomAccessIterator __pivot, _Compare __comp)
<span class="lineNum">    1894 </span>            :     {
<span class="lineNum">    1895 </span>            :       while (true)
<span class="lineNum">    1896 </span>            :         {
<span class="lineNum">    1897 </span><span class="lineNoCov">          0 :           while (__comp(__first, __pivot))</span>
<span class="lineNum">    1898 </span><span class="lineNoCov">          0 :             ++__first;</span>
<span class="lineNum">    1899 </span><span class="lineNoCov">          0 :           --__last;</span>
<span class="lineNum">    1900 </span><span class="lineNoCov">          0 :           while (__comp(__pivot, __last))</span>
<span class="lineNum">    1901 </span><span class="lineNoCov">          0 :             --__last;</span>
<span class="lineNum">    1902 </span><span class="lineNoCov">          0 :           if (!(__first &lt; __last))</span>
<span class="lineNum">    1903 </span>            :             return __first;
<span class="lineNum">    1904 </span>            :           std::iter_swap(__first, __last);
<span class="lineNum">    1905 </span><span class="lineNoCov">          0 :           ++__first;</span>
<span class="lineNum">    1906 </span>            :         }
<span class="lineNum">    1907 </span>            :     }
<span class="lineNum">    1908 </span>            : 
<span class="lineNum">    1909 </span>            :   /// This is a helper function...
<a name="1910"><span class="lineNum">    1910 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;</a>
<span class="lineNum">    1911 </span>            :     inline _RandomAccessIterator
<span class="lineNum">    1912 </span><span class="lineNoCov">          0 :     __unguarded_partition_pivot(_RandomAccessIterator __first,</span>
<span class="lineNum">    1913 </span>            :                                 _RandomAccessIterator __last, _Compare __comp)
<span class="lineNum">    1914 </span>            :     {
<span class="lineNum">    1915 </span><span class="lineNoCov">          0 :       _RandomAccessIterator __mid = __first + (__last - __first) / 2;</span>
<span class="lineNum">    1916 </span><span class="lineNoCov">          0 :       std::__move_median_to_first(__first, __first + 1, __mid, __last - 1,</span>
<span class="lineNum">    1917 </span>            :                                   __comp);
<span class="lineNum">    1918 </span><span class="lineNoCov">          0 :       return std::__unguarded_partition(__first + 1, __last, __first, __comp);</span>
<span class="lineNum">    1919 </span>            :     }
<span class="lineNum">    1920 </span>            : 
<a name="1921"><span class="lineNum">    1921 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;</a>
<span class="lineNum">    1922 </span>            :     inline void
<span class="lineNum">    1923 </span><span class="lineNoCov">          0 :     __partial_sort(_RandomAccessIterator __first,</span>
<span class="lineNum">    1924 </span>            :                    _RandomAccessIterator __middle,
<span class="lineNum">    1925 </span>            :                    _RandomAccessIterator __last,
<span class="lineNum">    1926 </span>            :                    _Compare __comp)
<span class="lineNum">    1927 </span>            :     {
<span class="lineNum">    1928 </span><span class="lineNoCov">          0 :       std::__heap_select(__first, __middle, __last, __comp);</span>
<span class="lineNum">    1929 </span><span class="lineNoCov">          0 :       std::__sort_heap(__first, __middle, __comp);</span>
<span class="lineNum">    1930 </span><span class="lineNoCov">          0 :     }</span>
<span class="lineNum">    1931 </span>            : 
<span class="lineNum">    1932 </span>            :   /// This is a helper function for the sort routine.
<a name="1933"><span class="lineNum">    1933 </span>            :   template&lt;typename _RandomAccessIterator, typename _Size, typename _Compare&gt;</a>
<span class="lineNum">    1934 </span>            :     void
<span class="lineNum">    1935 </span><span class="lineCov">          1 :     __introsort_loop(_RandomAccessIterator __first,</span>
<span class="lineNum">    1936 </span>            :                      _RandomAccessIterator __last,
<span class="lineNum">    1937 </span>            :                      _Size __depth_limit, _Compare __comp)
<span class="lineNum">    1938 </span>            :     {
<span class="lineNum">    1939 </span><span class="lineCov">          1 :       while (__last - __first &gt; int(_S_threshold))</span>
<span class="lineNum">    1940 </span>            :         {
<span class="lineNum">    1941 </span><span class="lineNoCov">          0 :           if (__depth_limit == 0)</span>
<span class="lineNum">    1942 </span>            :             {
<span class="lineNum">    1943 </span>            :               std::__partial_sort(__first, __last, __last, __comp);
<span class="lineNum">    1944 </span>            :               return;
<span class="lineNum">    1945 </span>            :             }
<span class="lineNum">    1946 </span><span class="lineNoCov">          0 :           --__depth_limit;</span>
<span class="lineNum">    1947 </span>            :           _RandomAccessIterator __cut =
<span class="lineNum">    1948 </span><span class="lineNoCov">          0 :             std::__unguarded_partition_pivot(__first, __last, __comp);</span>
<span class="lineNum">    1949 </span><span class="lineNoCov">          0 :           std::__introsort_loop(__cut, __last, __depth_limit, __comp);</span>
<span class="lineNum">    1950 </span>            :           __last = __cut;
<span class="lineNum">    1951 </span>            :         }
<span class="lineNum">    1952 </span>            :     }
<span class="lineNum">    1953 </span>            : 
<span class="lineNum">    1954 </span>            :   // sort
<span class="lineNum">    1955 </span>            : 
<a name="1956"><span class="lineNum">    1956 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;</a>
<span class="lineNum">    1957 </span>            :     inline void
<span class="lineNum">    1958 </span><span class="lineCov">          1 :     __sort(_RandomAccessIterator __first, _RandomAccessIterator __last,</span>
<span class="lineNum">    1959 </span>            :            _Compare __comp)
<span class="lineNum">    1960 </span>            :     {
<span class="lineNum">    1961 </span><span class="lineCov">          1 :       if (__first != __last)</span>
<span class="lineNum">    1962 </span>            :         {
<span class="lineNum">    1963 </span><span class="lineCov">          1 :           std::__introsort_loop(__first, __last,</span>
<span class="lineNum">    1964 </span><span class="lineCov">          1 :                                 std::__lg(__last - __first) * 2,</span>
<span class="lineNum">    1965 </span>            :                                 __comp);
<span class="lineNum">    1966 </span><span class="lineCov">          1 :           std::__final_insertion_sort(__first, __last, __comp);</span>
<span class="lineNum">    1967 </span>            :         }
<span class="lineNum">    1968 </span><span class="lineCov">          1 :     }</span>
<span class="lineNum">    1969 </span>            : 
<span class="lineNum">    1970 </span>            :   template&lt;typename _RandomAccessIterator, typename _Size, typename _Compare&gt;
<span class="lineNum">    1971 </span>            :     void
<span class="lineNum">    1972 </span>            :     __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth,
<span class="lineNum">    1973 </span>            :                   _RandomAccessIterator __last, _Size __depth_limit,
<span class="lineNum">    1974 </span>            :                   _Compare __comp)
<span class="lineNum">    1975 </span>            :     {
<span class="lineNum">    1976 </span>            :       while (__last - __first &gt; 3)
<span class="lineNum">    1977 </span>            :         {
<span class="lineNum">    1978 </span>            :           if (__depth_limit == 0)
<span class="lineNum">    1979 </span>            :             {
<span class="lineNum">    1980 </span>            :               std::__heap_select(__first, __nth + 1, __last, __comp);
<span class="lineNum">    1981 </span>            :               // Place the nth largest element in its final position.
<span class="lineNum">    1982 </span>            :               std::iter_swap(__first, __nth);
<span class="lineNum">    1983 </span>            :               return;
<span class="lineNum">    1984 </span>            :             }
<span class="lineNum">    1985 </span>            :           --__depth_limit;
<span class="lineNum">    1986 </span>            :           _RandomAccessIterator __cut =
<span class="lineNum">    1987 </span>            :             std::__unguarded_partition_pivot(__first, __last, __comp);
<span class="lineNum">    1988 </span>            :           if (__cut &lt;= __nth)
<span class="lineNum">    1989 </span>            :             __first = __cut;
<span class="lineNum">    1990 </span>            :           else
<span class="lineNum">    1991 </span>            :             __last = __cut;
<span class="lineNum">    1992 </span>            :         }
<span class="lineNum">    1993 </span>            :       std::__insertion_sort(__first, __last, __comp);
<span class="lineNum">    1994 </span>            :     }
<span class="lineNum">    1995 </span>            : 
<span class="lineNum">    1996 </span>            :   // nth_element
<span class="lineNum">    1997 </span>            : 
<span class="lineNum">    1998 </span>            :   // lower_bound moved to stl_algobase.h
<span class="lineNum">    1999 </span>            : 
<span class="lineNum">    2000 </span>            :   /**
<span class="lineNum">    2001 </span>            :    *  @brief Finds the first position in which @p __val could be inserted
<span class="lineNum">    2002 </span>            :    *         without changing the ordering.
<span class="lineNum">    2003 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2004 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2005 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2006 </span>            :    *  @param  __val     The search term.
<span class="lineNum">    2007 </span>            :    *  @param  __comp    A functor to use for comparisons.
<span class="lineNum">    2008 </span>            :    *  @return An iterator pointing to the first element &lt;em&gt;not less
<span class="lineNum">    2009 </span>            :    *           than&lt;/em&gt; @p __val, or end() if every element is less
<span class="lineNum">    2010 </span>            :    *           than @p __val.
<span class="lineNum">    2011 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2012 </span>            :    *
<span class="lineNum">    2013 </span>            :    *  The comparison function should have the same effects on ordering as
<span class="lineNum">    2014 </span>            :    *  the function used for the initial sort.
<span class="lineNum">    2015 </span>            :   */
<span class="lineNum">    2016 </span>            :   template&lt;typename _ForwardIterator, typename _Tp, typename _Compare&gt;
<span class="lineNum">    2017 </span>            :     inline _ForwardIterator
<span class="lineNum">    2018 </span>            :     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2019 </span>            :                 const _Tp&amp; __val, _Compare __comp)
<span class="lineNum">    2020 </span>            :     {
<span class="lineNum">    2021 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    2022 </span>            :         _ValueType;
<span class="lineNum">    2023 </span>            : 
<span class="lineNum">    2024 </span>            :       // concept requirements
<span class="lineNum">    2025 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    2026 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2027 </span>            :                                   _ValueType, _Tp&gt;)
<span class="lineNum">    2028 </span>            :       __glibcxx_requires_partitioned_lower_pred(__first, __last,
<span class="lineNum">    2029 </span>            :                                                 __val, __comp);
<span class="lineNum">    2030 </span>            : 
<span class="lineNum">    2031 </span>            :       return std::__lower_bound(__first, __last, __val,
<span class="lineNum">    2032 </span>            :                                 __gnu_cxx::__ops::__iter_comp_val(__comp));
<span class="lineNum">    2033 </span>            :     }
<span class="lineNum">    2034 </span>            : 
<span class="lineNum">    2035 </span>            :   template&lt;typename _ForwardIterator, typename _Tp, typename _Compare&gt;
<span class="lineNum">    2036 </span>            :     _ForwardIterator
<span class="lineNum">    2037 </span>            :     __upper_bound(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2038 </span>            :                   const _Tp&amp; __val, _Compare __comp)
<span class="lineNum">    2039 </span>            :     {
<span class="lineNum">    2040 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::difference_type
<span class="lineNum">    2041 </span>            :         _DistanceType;
<span class="lineNum">    2042 </span>            : 
<span class="lineNum">    2043 </span>            :       _DistanceType __len = std::distance(__first, __last);
<span class="lineNum">    2044 </span>            : 
<span class="lineNum">    2045 </span>            :       while (__len &gt; 0)
<span class="lineNum">    2046 </span>            :         {
<span class="lineNum">    2047 </span>            :           _DistanceType __half = __len &gt;&gt; 1;
<span class="lineNum">    2048 </span>            :           _ForwardIterator __middle = __first;
<span class="lineNum">    2049 </span>            :           std::advance(__middle, __half);
<span class="lineNum">    2050 </span>            :           if (__comp(__val, __middle))
<span class="lineNum">    2051 </span>            :             __len = __half;
<span class="lineNum">    2052 </span>            :           else
<span class="lineNum">    2053 </span>            :             {
<span class="lineNum">    2054 </span>            :               __first = __middle;
<span class="lineNum">    2055 </span>            :               ++__first;
<span class="lineNum">    2056 </span>            :               __len = __len - __half - 1;
<span class="lineNum">    2057 </span>            :             }
<span class="lineNum">    2058 </span>            :         }
<span class="lineNum">    2059 </span>            :       return __first;
<span class="lineNum">    2060 </span>            :     }
<span class="lineNum">    2061 </span>            : 
<span class="lineNum">    2062 </span>            :   /**
<span class="lineNum">    2063 </span>            :    *  @brief Finds the last position in which @p __val could be inserted
<span class="lineNum">    2064 </span>            :    *         without changing the ordering.
<span class="lineNum">    2065 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2066 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2067 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2068 </span>            :    *  @param  __val     The search term.
<span class="lineNum">    2069 </span>            :    *  @return  An iterator pointing to the first element greater than @p __val,
<span class="lineNum">    2070 </span>            :    *           or end() if no elements are greater than @p __val.
<span class="lineNum">    2071 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2072 </span>            :   */
<span class="lineNum">    2073 </span>            :   template&lt;typename _ForwardIterator, typename _Tp&gt;
<span class="lineNum">    2074 </span>            :     inline _ForwardIterator
<span class="lineNum">    2075 </span>            :     upper_bound(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2076 </span>            :                 const _Tp&amp; __val)
<span class="lineNum">    2077 </span>            :     {
<span class="lineNum">    2078 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    2079 </span>            :         _ValueType;
<span class="lineNum">    2080 </span>            : 
<span class="lineNum">    2081 </span>            :       // concept requirements
<span class="lineNum">    2082 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    2083 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;_Tp, _ValueType&gt;)
<span class="lineNum">    2084 </span>            :       __glibcxx_requires_partitioned_upper(__first, __last, __val);
<span class="lineNum">    2085 </span>            : 
<span class="lineNum">    2086 </span>            :       return std::__upper_bound(__first, __last, __val,
<span class="lineNum">    2087 </span>            :                                 __gnu_cxx::__ops::__val_less_iter());
<span class="lineNum">    2088 </span>            :     }
<span class="lineNum">    2089 </span>            : 
<span class="lineNum">    2090 </span>            :   /**
<span class="lineNum">    2091 </span>            :    *  @brief Finds the last position in which @p __val could be inserted
<span class="lineNum">    2092 </span>            :    *         without changing the ordering.
<span class="lineNum">    2093 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2094 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2095 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2096 </span>            :    *  @param  __val     The search term.
<span class="lineNum">    2097 </span>            :    *  @param  __comp    A functor to use for comparisons.
<span class="lineNum">    2098 </span>            :    *  @return  An iterator pointing to the first element greater than @p __val,
<span class="lineNum">    2099 </span>            :    *           or end() if no elements are greater than @p __val.
<span class="lineNum">    2100 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2101 </span>            :    *
<span class="lineNum">    2102 </span>            :    *  The comparison function should have the same effects on ordering as
<span class="lineNum">    2103 </span>            :    *  the function used for the initial sort.
<span class="lineNum">    2104 </span>            :   */
<span class="lineNum">    2105 </span>            :   template&lt;typename _ForwardIterator, typename _Tp, typename _Compare&gt;
<span class="lineNum">    2106 </span>            :     inline _ForwardIterator
<span class="lineNum">    2107 </span>            :     upper_bound(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2108 </span>            :                 const _Tp&amp; __val, _Compare __comp)
<span class="lineNum">    2109 </span>            :     {
<span class="lineNum">    2110 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    2111 </span>            :         _ValueType;
<span class="lineNum">    2112 </span>            : 
<span class="lineNum">    2113 </span>            :       // concept requirements
<span class="lineNum">    2114 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    2115 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2116 </span>            :                                   _Tp, _ValueType&gt;)
<span class="lineNum">    2117 </span>            :       __glibcxx_requires_partitioned_upper_pred(__first, __last,
<span class="lineNum">    2118 </span>            :                                                 __val, __comp);
<span class="lineNum">    2119 </span>            : 
<span class="lineNum">    2120 </span>            :       return std::__upper_bound(__first, __last, __val,
<span class="lineNum">    2121 </span>            :                                 __gnu_cxx::__ops::__val_comp_iter(__comp));
<span class="lineNum">    2122 </span>            :     }
<span class="lineNum">    2123 </span>            : 
<span class="lineNum">    2124 </span>            :   template&lt;typename _ForwardIterator, typename _Tp,
<span class="lineNum">    2125 </span>            :            typename _CompareItTp, typename _CompareTpIt&gt;
<span class="lineNum">    2126 </span>            :     pair&lt;_ForwardIterator, _ForwardIterator&gt;
<span class="lineNum">    2127 </span>            :     __equal_range(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2128 </span>            :                   const _Tp&amp; __val,
<span class="lineNum">    2129 </span>            :                   _CompareItTp __comp_it_val, _CompareTpIt __comp_val_it)
<span class="lineNum">    2130 </span>            :     {
<span class="lineNum">    2131 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::difference_type
<span class="lineNum">    2132 </span>            :         _DistanceType;
<span class="lineNum">    2133 </span>            : 
<span class="lineNum">    2134 </span>            :       _DistanceType __len = std::distance(__first, __last);
<span class="lineNum">    2135 </span>            : 
<span class="lineNum">    2136 </span>            :       while (__len &gt; 0)
<span class="lineNum">    2137 </span>            :         {
<span class="lineNum">    2138 </span>            :           _DistanceType __half = __len &gt;&gt; 1;
<span class="lineNum">    2139 </span>            :           _ForwardIterator __middle = __first;
<span class="lineNum">    2140 </span>            :           std::advance(__middle, __half);
<span class="lineNum">    2141 </span>            :           if (__comp_it_val(__middle, __val))
<span class="lineNum">    2142 </span>            :             {
<span class="lineNum">    2143 </span>            :               __first = __middle;
<span class="lineNum">    2144 </span>            :               ++__first;
<span class="lineNum">    2145 </span>            :               __len = __len - __half - 1;
<span class="lineNum">    2146 </span>            :             }
<span class="lineNum">    2147 </span>            :           else if (__comp_val_it(__val, __middle))
<span class="lineNum">    2148 </span>            :             __len = __half;
<span class="lineNum">    2149 </span>            :           else
<span class="lineNum">    2150 </span>            :             {
<span class="lineNum">    2151 </span>            :               _ForwardIterator __left
<span class="lineNum">    2152 </span>            :                 = std::__lower_bound(__first, __middle, __val, __comp_it_val);
<span class="lineNum">    2153 </span>            :               std::advance(__first, __len);
<span class="lineNum">    2154 </span>            :               _ForwardIterator __right
<span class="lineNum">    2155 </span>            :                 = std::__upper_bound(++__middle, __first, __val, __comp_val_it);
<span class="lineNum">    2156 </span>            :               return pair&lt;_ForwardIterator, _ForwardIterator&gt;(__left, __right);
<span class="lineNum">    2157 </span>            :             }
<span class="lineNum">    2158 </span>            :         }
<span class="lineNum">    2159 </span>            :       return pair&lt;_ForwardIterator, _ForwardIterator&gt;(__first, __first);
<span class="lineNum">    2160 </span>            :     }
<span class="lineNum">    2161 </span>            : 
<span class="lineNum">    2162 </span>            :   /**
<span class="lineNum">    2163 </span>            :    *  @brief Finds the largest subrange in which @p __val could be inserted
<span class="lineNum">    2164 </span>            :    *         at any place in it without changing the ordering.
<span class="lineNum">    2165 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2166 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2167 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2168 </span>            :    *  @param  __val     The search term.
<span class="lineNum">    2169 </span>            :    *  @return  An pair of iterators defining the subrange.
<span class="lineNum">    2170 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2171 </span>            :    *
<span class="lineNum">    2172 </span>            :    *  This is equivalent to
<span class="lineNum">    2173 </span>            :    *  @code
<span class="lineNum">    2174 </span>            :    *    std::make_pair(lower_bound(__first, __last, __val),
<span class="lineNum">    2175 </span>            :    *                   upper_bound(__first, __last, __val))
<span class="lineNum">    2176 </span>            :    *  @endcode
<span class="lineNum">    2177 </span>            :    *  but does not actually call those functions.
<span class="lineNum">    2178 </span>            :   */
<span class="lineNum">    2179 </span>            :   template&lt;typename _ForwardIterator, typename _Tp&gt;
<span class="lineNum">    2180 </span>            :     inline pair&lt;_ForwardIterator, _ForwardIterator&gt;
<span class="lineNum">    2181 </span>            :     equal_range(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2182 </span>            :                 const _Tp&amp; __val)
<span class="lineNum">    2183 </span>            :     {
<span class="lineNum">    2184 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    2185 </span>            :         _ValueType;
<span class="lineNum">    2186 </span>            : 
<span class="lineNum">    2187 </span>            :       // concept requirements
<span class="lineNum">    2188 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    2189 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;_ValueType, _Tp&gt;)
<span class="lineNum">    2190 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;_Tp, _ValueType&gt;)
<span class="lineNum">    2191 </span>            :       __glibcxx_requires_partitioned_lower(__first, __last, __val);
<span class="lineNum">    2192 </span>            :       __glibcxx_requires_partitioned_upper(__first, __last, __val);      
<span class="lineNum">    2193 </span>            : 
<span class="lineNum">    2194 </span>            :       return std::__equal_range(__first, __last, __val,
<span class="lineNum">    2195 </span>            :                                 __gnu_cxx::__ops::__iter_less_val(),
<span class="lineNum">    2196 </span>            :                                 __gnu_cxx::__ops::__val_less_iter());
<span class="lineNum">    2197 </span>            :     }
<span class="lineNum">    2198 </span>            : 
<span class="lineNum">    2199 </span>            :   /**
<span class="lineNum">    2200 </span>            :    *  @brief Finds the largest subrange in which @p __val could be inserted
<span class="lineNum">    2201 </span>            :    *         at any place in it without changing the ordering.
<span class="lineNum">    2202 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2203 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2204 </span>            :    *  @param  __val     The search term.
<span class="lineNum">    2205 </span>            :    *  @param  __comp    A functor to use for comparisons.
<span class="lineNum">    2206 </span>            :    *  @return  An pair of iterators defining the subrange.
<span class="lineNum">    2207 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2208 </span>            :    *
<span class="lineNum">    2209 </span>            :    *  This is equivalent to
<span class="lineNum">    2210 </span>            :    *  @code
<span class="lineNum">    2211 </span>            :    *    std::make_pair(lower_bound(__first, __last, __val, __comp),
<span class="lineNum">    2212 </span>            :    *                   upper_bound(__first, __last, __val, __comp))
<span class="lineNum">    2213 </span>            :    *  @endcode
<span class="lineNum">    2214 </span>            :    *  but does not actually call those functions.
<span class="lineNum">    2215 </span>            :   */
<span class="lineNum">    2216 </span>            :   template&lt;typename _ForwardIterator, typename _Tp, typename _Compare&gt;
<span class="lineNum">    2217 </span>            :     inline pair&lt;_ForwardIterator, _ForwardIterator&gt;
<span class="lineNum">    2218 </span>            :     equal_range(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2219 </span>            :                 const _Tp&amp; __val, _Compare __comp)
<span class="lineNum">    2220 </span>            :     {
<span class="lineNum">    2221 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    2222 </span>            :         _ValueType;
<span class="lineNum">    2223 </span>            : 
<span class="lineNum">    2224 </span>            :       // concept requirements
<span class="lineNum">    2225 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    2226 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2227 </span>            :                                   _ValueType, _Tp&gt;)
<span class="lineNum">    2228 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2229 </span>            :                                   _Tp, _ValueType&gt;)
<span class="lineNum">    2230 </span>            :       __glibcxx_requires_partitioned_lower_pred(__first, __last,
<span class="lineNum">    2231 </span>            :                                                 __val, __comp);
<span class="lineNum">    2232 </span>            :       __glibcxx_requires_partitioned_upper_pred(__first, __last,
<span class="lineNum">    2233 </span>            :                                                 __val, __comp);
<span class="lineNum">    2234 </span>            : 
<span class="lineNum">    2235 </span>            :       return std::__equal_range(__first, __last, __val,
<span class="lineNum">    2236 </span>            :                                 __gnu_cxx::__ops::__iter_comp_val(__comp),
<span class="lineNum">    2237 </span>            :                                 __gnu_cxx::__ops::__val_comp_iter(__comp));
<span class="lineNum">    2238 </span>            :     }
<span class="lineNum">    2239 </span>            : 
<span class="lineNum">    2240 </span>            :   /**
<span class="lineNum">    2241 </span>            :    *  @brief Determines whether an element exists in a range.
<span class="lineNum">    2242 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2243 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2244 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2245 </span>            :    *  @param  __val     The search term.
<span class="lineNum">    2246 </span>            :    *  @return True if @p __val (or its equivalent) is in [@p
<span class="lineNum">    2247 </span>            :    *  __first,@p __last ].
<span class="lineNum">    2248 </span>            :    *
<span class="lineNum">    2249 </span>            :    *  Note that this does not actually return an iterator to @p __val.  For
<span class="lineNum">    2250 </span>            :    *  that, use std::find or a container's specialized find member functions.
<span class="lineNum">    2251 </span>            :   */
<span class="lineNum">    2252 </span>            :   template&lt;typename _ForwardIterator, typename _Tp&gt;
<span class="lineNum">    2253 </span>            :     bool
<span class="lineNum">    2254 </span>            :     binary_search(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2255 </span>            :                   const _Tp&amp; __val)
<span class="lineNum">    2256 </span>            :     {
<span class="lineNum">    2257 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    2258 </span>            :         _ValueType;
<span class="lineNum">    2259 </span>            : 
<span class="lineNum">    2260 </span>            :       // concept requirements
<span class="lineNum">    2261 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    2262 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;_Tp, _ValueType&gt;)
<span class="lineNum">    2263 </span>            :       __glibcxx_requires_partitioned_lower(__first, __last, __val);
<span class="lineNum">    2264 </span>            :       __glibcxx_requires_partitioned_upper(__first, __last, __val);
<span class="lineNum">    2265 </span>            : 
<span class="lineNum">    2266 </span>            :       _ForwardIterator __i
<span class="lineNum">    2267 </span>            :         = std::__lower_bound(__first, __last, __val,
<span class="lineNum">    2268 </span>            :                              __gnu_cxx::__ops::__iter_less_val());
<span class="lineNum">    2269 </span><span class="lineNoCov">          0 :       return __i != __last &amp;&amp; !(__val &lt; *__i);</span>
<span class="lineNum">    2270 </span>            :     }
<span class="lineNum">    2271 </span>            : 
<span class="lineNum">    2272 </span>            :   /**
<span class="lineNum">    2273 </span>            :    *  @brief Determines whether an element exists in a range.
<span class="lineNum">    2274 </span>            :    *  @ingroup binary_search_algorithms
<span class="lineNum">    2275 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2276 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2277 </span>            :    *  @param  __val     The search term.
<span class="lineNum">    2278 </span>            :    *  @param  __comp    A functor to use for comparisons.
<span class="lineNum">    2279 </span>            :    *  @return  True if @p __val (or its equivalent) is in @p [__first,__last].
<span class="lineNum">    2280 </span>            :    *
<span class="lineNum">    2281 </span>            :    *  Note that this does not actually return an iterator to @p __val.  For
<span class="lineNum">    2282 </span>            :    *  that, use std::find or a container's specialized find member functions.
<span class="lineNum">    2283 </span>            :    *
<span class="lineNum">    2284 </span>            :    *  The comparison function should have the same effects on ordering as
<span class="lineNum">    2285 </span>            :    *  the function used for the initial sort.
<span class="lineNum">    2286 </span>            :   */
<span class="lineNum">    2287 </span>            :   template&lt;typename _ForwardIterator, typename _Tp, typename _Compare&gt;
<span class="lineNum">    2288 </span>            :     bool
<span class="lineNum">    2289 </span>            :     binary_search(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    2290 </span>            :                   const _Tp&amp; __val, _Compare __comp)
<span class="lineNum">    2291 </span>            :     {
<span class="lineNum">    2292 </span>            :       typedef typename iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    2293 </span>            :         _ValueType;
<span class="lineNum">    2294 </span>            : 
<span class="lineNum">    2295 </span>            :       // concept requirements
<span class="lineNum">    2296 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    2297 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2298 </span>            :                                   _Tp, _ValueType&gt;)
<span class="lineNum">    2299 </span>            :       __glibcxx_requires_partitioned_lower_pred(__first, __last,
<span class="lineNum">    2300 </span>            :                                                 __val, __comp);
<span class="lineNum">    2301 </span>            :       __glibcxx_requires_partitioned_upper_pred(__first, __last,
<span class="lineNum">    2302 </span>            :                                                 __val, __comp);
<span class="lineNum">    2303 </span>            : 
<span class="lineNum">    2304 </span>            :       _ForwardIterator __i
<span class="lineNum">    2305 </span>            :         = std::__lower_bound(__first, __last, __val,
<span class="lineNum">    2306 </span>            :                              __gnu_cxx::__ops::__iter_comp_val(__comp));
<span class="lineNum">    2307 </span>            :       return __i != __last &amp;&amp; !bool(__comp(__val, *__i));
<span class="lineNum">    2308 </span>            :     }
<span class="lineNum">    2309 </span>            : 
<span class="lineNum">    2310 </span>            :   // merge
<span class="lineNum">    2311 </span>            : 
<span class="lineNum">    2312 </span>            :   /// This is a helper function for the __merge_adaptive routines.
<span class="lineNum">    2313 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    2314 </span>            :            typename _OutputIterator, typename _Compare&gt;
<span class="lineNum">    2315 </span>            :     void
<span class="lineNum">    2316 </span>            :     __move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    2317 </span>            :                           _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    2318 </span>            :                           _OutputIterator __result, _Compare __comp)
<span class="lineNum">    2319 </span>            :     {
<span class="lineNum">    2320 </span>            :       while (__first1 != __last1 &amp;&amp; __first2 != __last2)
<span class="lineNum">    2321 </span>            :         {
<span class="lineNum">    2322 </span>            :           if (__comp(__first2, __first1))
<span class="lineNum">    2323 </span>            :             {
<span class="lineNum">    2324 </span>            :               *__result = _GLIBCXX_MOVE(*__first2);
<span class="lineNum">    2325 </span>            :               ++__first2;
<span class="lineNum">    2326 </span>            :             }
<span class="lineNum">    2327 </span>            :           else
<span class="lineNum">    2328 </span>            :             {
<span class="lineNum">    2329 </span>            :               *__result = _GLIBCXX_MOVE(*__first1);
<span class="lineNum">    2330 </span>            :               ++__first1;
<span class="lineNum">    2331 </span>            :             }
<span class="lineNum">    2332 </span>            :           ++__result;
<span class="lineNum">    2333 </span>            :         }
<span class="lineNum">    2334 </span>            :       if (__first1 != __last1)
<span class="lineNum">    2335 </span>            :         _GLIBCXX_MOVE3(__first1, __last1, __result);
<span class="lineNum">    2336 </span>            :     }
<span class="lineNum">    2337 </span>            : 
<span class="lineNum">    2338 </span>            :   /// This is a helper function for the __merge_adaptive routines.
<span class="lineNum">    2339 </span>            :   template&lt;typename _BidirectionalIterator1, typename _BidirectionalIterator2,
<span class="lineNum">    2340 </span>            :            typename _BidirectionalIterator3, typename _Compare&gt;
<span class="lineNum">    2341 </span>            :     void
<span class="lineNum">    2342 </span>            :     __move_merge_adaptive_backward(_BidirectionalIterator1 __first1,
<span class="lineNum">    2343 </span>            :                                    _BidirectionalIterator1 __last1,
<span class="lineNum">    2344 </span>            :                                    _BidirectionalIterator2 __first2,
<span class="lineNum">    2345 </span>            :                                    _BidirectionalIterator2 __last2,
<span class="lineNum">    2346 </span>            :                                    _BidirectionalIterator3 __result,
<span class="lineNum">    2347 </span>            :                                    _Compare __comp)
<span class="lineNum">    2348 </span>            :     {
<span class="lineNum">    2349 </span>            :       if (__first1 == __last1)
<span class="lineNum">    2350 </span>            :         {
<span class="lineNum">    2351 </span>            :           _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result);
<span class="lineNum">    2352 </span>            :           return;
<span class="lineNum">    2353 </span>            :         }
<span class="lineNum">    2354 </span>            :       else if (__first2 == __last2)
<span class="lineNum">    2355 </span>            :         return;
<span class="lineNum">    2356 </span>            : 
<span class="lineNum">    2357 </span>            :       --__last1;
<span class="lineNum">    2358 </span>            :       --__last2;
<span class="lineNum">    2359 </span>            :       while (true)
<span class="lineNum">    2360 </span>            :         {
<span class="lineNum">    2361 </span>            :           if (__comp(__last2, __last1))
<span class="lineNum">    2362 </span>            :             {
<span class="lineNum">    2363 </span>            :               *--__result = _GLIBCXX_MOVE(*__last1);
<span class="lineNum">    2364 </span>            :               if (__first1 == __last1)
<span class="lineNum">    2365 </span>            :                 {
<span class="lineNum">    2366 </span>            :                   _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result);
<span class="lineNum">    2367 </span>            :                   return;
<span class="lineNum">    2368 </span>            :                 }
<span class="lineNum">    2369 </span>            :               --__last1;
<span class="lineNum">    2370 </span>            :             }
<span class="lineNum">    2371 </span>            :           else
<span class="lineNum">    2372 </span>            :             {
<span class="lineNum">    2373 </span>            :               *--__result = _GLIBCXX_MOVE(*__last2);
<span class="lineNum">    2374 </span>            :               if (__first2 == __last2)
<span class="lineNum">    2375 </span>            :                 return;
<span class="lineNum">    2376 </span>            :               --__last2;
<span class="lineNum">    2377 </span>            :             }
<span class="lineNum">    2378 </span>            :         }
<span class="lineNum">    2379 </span>            :     }
<span class="lineNum">    2380 </span>            : 
<span class="lineNum">    2381 </span>            :   /// This is a helper function for the merge routines.
<span class="lineNum">    2382 </span>            :   template&lt;typename _BidirectionalIterator1, typename _BidirectionalIterator2,
<span class="lineNum">    2383 </span>            :            typename _Distance&gt;
<span class="lineNum">    2384 </span>            :     _BidirectionalIterator1
<span class="lineNum">    2385 </span>            :     __rotate_adaptive(_BidirectionalIterator1 __first,
<span class="lineNum">    2386 </span>            :                       _BidirectionalIterator1 __middle,
<span class="lineNum">    2387 </span>            :                       _BidirectionalIterator1 __last,
<span class="lineNum">    2388 </span>            :                       _Distance __len1, _Distance __len2,
<span class="lineNum">    2389 </span>            :                       _BidirectionalIterator2 __buffer,
<span class="lineNum">    2390 </span>            :                       _Distance __buffer_size)
<span class="lineNum">    2391 </span>            :     {
<span class="lineNum">    2392 </span>            :       _BidirectionalIterator2 __buffer_end;
<span class="lineNum">    2393 </span>            :       if (__len1 &gt; __len2 &amp;&amp; __len2 &lt;= __buffer_size)
<span class="lineNum">    2394 </span>            :         {
<span class="lineNum">    2395 </span>            :           if (__len2)
<span class="lineNum">    2396 </span>            :             {
<span class="lineNum">    2397 </span>            :               __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
<span class="lineNum">    2398 </span>            :               _GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last);
<span class="lineNum">    2399 </span>            :               return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first);
<span class="lineNum">    2400 </span>            :             }
<span class="lineNum">    2401 </span>            :           else
<span class="lineNum">    2402 </span>            :             return __first;
<span class="lineNum">    2403 </span>            :         }
<span class="lineNum">    2404 </span>            :       else if (__len1 &lt;= __buffer_size)
<span class="lineNum">    2405 </span>            :         {
<span class="lineNum">    2406 </span>            :           if (__len1)
<span class="lineNum">    2407 </span>            :             {
<span class="lineNum">    2408 </span>            :               __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
<span class="lineNum">    2409 </span>            :               _GLIBCXX_MOVE3(__middle, __last, __first);
<span class="lineNum">    2410 </span>            :               return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last);
<span class="lineNum">    2411 </span>            :             }
<span class="lineNum">    2412 </span>            :           else
<span class="lineNum">    2413 </span>            :             return __last;
<span class="lineNum">    2414 </span>            :         }
<span class="lineNum">    2415 </span>            :       else
<span class="lineNum">    2416 </span>            :         {
<span class="lineNum">    2417 </span>            :           std::rotate(__first, __middle, __last);
<span class="lineNum">    2418 </span>            :           std::advance(__first, std::distance(__middle, __last));
<span class="lineNum">    2419 </span>            :           return __first;
<span class="lineNum">    2420 </span>            :         }
<span class="lineNum">    2421 </span>            :     }
<span class="lineNum">    2422 </span>            : 
<span class="lineNum">    2423 </span>            :   /// This is a helper function for the merge routines.
<span class="lineNum">    2424 </span>            :   template&lt;typename _BidirectionalIterator, typename _Distance, 
<span class="lineNum">    2425 </span>            :            typename _Pointer, typename _Compare&gt;
<span class="lineNum">    2426 </span>            :     void
<span class="lineNum">    2427 </span>            :     __merge_adaptive(_BidirectionalIterator __first,
<span class="lineNum">    2428 </span>            :                      _BidirectionalIterator __middle,
<span class="lineNum">    2429 </span>            :                      _BidirectionalIterator __last,
<span class="lineNum">    2430 </span>            :                      _Distance __len1, _Distance __len2,
<span class="lineNum">    2431 </span>            :                      _Pointer __buffer, _Distance __buffer_size,
<span class="lineNum">    2432 </span>            :                      _Compare __comp)
<span class="lineNum">    2433 </span>            :     {
<span class="lineNum">    2434 </span>            :       if (__len1 &lt;= __len2 &amp;&amp; __len1 &lt;= __buffer_size)
<span class="lineNum">    2435 </span>            :         {
<span class="lineNum">    2436 </span>            :           _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
<span class="lineNum">    2437 </span>            :           std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last,
<span class="lineNum">    2438 </span>            :                                      __first, __comp);
<span class="lineNum">    2439 </span>            :         }
<span class="lineNum">    2440 </span>            :       else if (__len2 &lt;= __buffer_size)
<span class="lineNum">    2441 </span>            :         {
<span class="lineNum">    2442 </span>            :           _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
<span class="lineNum">    2443 </span>            :           std::__move_merge_adaptive_backward(__first, __middle, __buffer,
<span class="lineNum">    2444 </span>            :                                               __buffer_end, __last, __comp);
<span class="lineNum">    2445 </span>            :         }
<span class="lineNum">    2446 </span>            :       else
<span class="lineNum">    2447 </span>            :         {
<span class="lineNum">    2448 </span>            :           _BidirectionalIterator __first_cut = __first;
<span class="lineNum">    2449 </span>            :           _BidirectionalIterator __second_cut = __middle;
<span class="lineNum">    2450 </span>            :           _Distance __len11 = 0;
<span class="lineNum">    2451 </span>            :           _Distance __len22 = 0;
<span class="lineNum">    2452 </span>            :           if (__len1 &gt; __len2)
<span class="lineNum">    2453 </span>            :             {
<span class="lineNum">    2454 </span>            :               __len11 = __len1 / 2;
<span class="lineNum">    2455 </span>            :               std::advance(__first_cut, __len11);
<span class="lineNum">    2456 </span>            :               __second_cut
<span class="lineNum">    2457 </span>            :                 = std::__lower_bound(__middle, __last, *__first_cut,
<span class="lineNum">    2458 </span>            :                                      __gnu_cxx::__ops::__iter_comp_val(__comp));
<span class="lineNum">    2459 </span>            :               __len22 = std::distance(__middle, __second_cut);
<span class="lineNum">    2460 </span>            :             }
<span class="lineNum">    2461 </span>            :           else
<span class="lineNum">    2462 </span>            :             {
<span class="lineNum">    2463 </span>            :               __len22 = __len2 / 2;
<span class="lineNum">    2464 </span>            :               std::advance(__second_cut, __len22);
<span class="lineNum">    2465 </span>            :               __first_cut
<span class="lineNum">    2466 </span>            :                 = std::__upper_bound(__first, __middle, *__second_cut,
<span class="lineNum">    2467 </span>            :                                      __gnu_cxx::__ops::__val_comp_iter(__comp));
<span class="lineNum">    2468 </span>            :               __len11 = std::distance(__first, __first_cut);
<span class="lineNum">    2469 </span>            :             }
<span class="lineNum">    2470 </span>            : 
<span class="lineNum">    2471 </span>            :           _BidirectionalIterator __new_middle
<span class="lineNum">    2472 </span>            :             = std::__rotate_adaptive(__first_cut, __middle, __second_cut,
<span class="lineNum">    2473 </span>            :                                      __len1 - __len11, __len22, __buffer,
<span class="lineNum">    2474 </span>            :                                      __buffer_size);
<span class="lineNum">    2475 </span>            :           std::__merge_adaptive(__first, __first_cut, __new_middle, __len11,
<span class="lineNum">    2476 </span>            :                                 __len22, __buffer, __buffer_size, __comp);
<span class="lineNum">    2477 </span>            :           std::__merge_adaptive(__new_middle, __second_cut, __last,
<span class="lineNum">    2478 </span>            :                                 __len1 - __len11,
<span class="lineNum">    2479 </span>            :                                 __len2 - __len22, __buffer,
<span class="lineNum">    2480 </span>            :                                 __buffer_size, __comp);
<span class="lineNum">    2481 </span>            :         }
<span class="lineNum">    2482 </span>            :     }
<span class="lineNum">    2483 </span>            : 
<span class="lineNum">    2484 </span>            :   /// This is a helper function for the merge routines.
<span class="lineNum">    2485 </span>            :   template&lt;typename _BidirectionalIterator, typename _Distance,
<span class="lineNum">    2486 </span>            :            typename _Compare&gt;
<span class="lineNum">    2487 </span>            :     void
<span class="lineNum">    2488 </span>            :     __merge_without_buffer(_BidirectionalIterator __first,
<span class="lineNum">    2489 </span>            :                            _BidirectionalIterator __middle,
<span class="lineNum">    2490 </span>            :                            _BidirectionalIterator __last,
<span class="lineNum">    2491 </span>            :                            _Distance __len1, _Distance __len2,
<span class="lineNum">    2492 </span>            :                            _Compare __comp)
<span class="lineNum">    2493 </span>            :     {
<span class="lineNum">    2494 </span>            :       if (__len1 == 0 || __len2 == 0)
<span class="lineNum">    2495 </span>            :         return;
<span class="lineNum">    2496 </span>            : 
<span class="lineNum">    2497 </span>            :       if (__len1 + __len2 == 2)
<span class="lineNum">    2498 </span>            :         {
<span class="lineNum">    2499 </span>            :           if (__comp(__middle, __first))
<span class="lineNum">    2500 </span>            :             std::iter_swap(__first, __middle);
<span class="lineNum">    2501 </span>            :           return;
<span class="lineNum">    2502 </span>            :         }
<span class="lineNum">    2503 </span>            : 
<span class="lineNum">    2504 </span>            :       _BidirectionalIterator __first_cut = __first;
<span class="lineNum">    2505 </span>            :       _BidirectionalIterator __second_cut = __middle;
<span class="lineNum">    2506 </span>            :       _Distance __len11 = 0;
<span class="lineNum">    2507 </span>            :       _Distance __len22 = 0;
<span class="lineNum">    2508 </span>            :       if (__len1 &gt; __len2)
<span class="lineNum">    2509 </span>            :         {
<span class="lineNum">    2510 </span>            :           __len11 = __len1 / 2;
<span class="lineNum">    2511 </span>            :           std::advance(__first_cut, __len11);
<span class="lineNum">    2512 </span>            :           __second_cut
<span class="lineNum">    2513 </span>            :             = std::__lower_bound(__middle, __last, *__first_cut,
<span class="lineNum">    2514 </span>            :                                  __gnu_cxx::__ops::__iter_comp_val(__comp));
<span class="lineNum">    2515 </span>            :           __len22 = std::distance(__middle, __second_cut);
<span class="lineNum">    2516 </span>            :         }
<span class="lineNum">    2517 </span>            :       else
<span class="lineNum">    2518 </span>            :         {
<span class="lineNum">    2519 </span>            :           __len22 = __len2 / 2;
<span class="lineNum">    2520 </span>            :           std::advance(__second_cut, __len22);
<span class="lineNum">    2521 </span>            :           __first_cut
<span class="lineNum">    2522 </span>            :             = std::__upper_bound(__first, __middle, *__second_cut,
<span class="lineNum">    2523 </span>            :                                  __gnu_cxx::__ops::__val_comp_iter(__comp));
<span class="lineNum">    2524 </span>            :           __len11 = std::distance(__first, __first_cut);
<span class="lineNum">    2525 </span>            :         }
<span class="lineNum">    2526 </span>            : 
<span class="lineNum">    2527 </span>            :       std::rotate(__first_cut, __middle, __second_cut);
<span class="lineNum">    2528 </span>            :       _BidirectionalIterator __new_middle = __first_cut;
<span class="lineNum">    2529 </span>            :       std::advance(__new_middle, std::distance(__middle, __second_cut));
<span class="lineNum">    2530 </span>            :       std::__merge_without_buffer(__first, __first_cut, __new_middle,
<span class="lineNum">    2531 </span>            :                                   __len11, __len22, __comp);
<span class="lineNum">    2532 </span>            :       std::__merge_without_buffer(__new_middle, __second_cut, __last,
<span class="lineNum">    2533 </span>            :                                   __len1 - __len11, __len2 - __len22, __comp);
<span class="lineNum">    2534 </span>            :     }
<span class="lineNum">    2535 </span>            : 
<span class="lineNum">    2536 </span>            :   template&lt;typename _BidirectionalIterator, typename _Compare&gt;
<span class="lineNum">    2537 </span>            :     void
<span class="lineNum">    2538 </span>            :     __inplace_merge(_BidirectionalIterator __first,
<span class="lineNum">    2539 </span>            :                     _BidirectionalIterator __middle,
<span class="lineNum">    2540 </span>            :                     _BidirectionalIterator __last,
<span class="lineNum">    2541 </span>            :                     _Compare __comp)
<span class="lineNum">    2542 </span>            :     {
<span class="lineNum">    2543 </span>            :       typedef typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type
<span class="lineNum">    2544 </span>            :           _ValueType;
<span class="lineNum">    2545 </span>            :       typedef typename iterator_traits&lt;_BidirectionalIterator&gt;::difference_type
<span class="lineNum">    2546 </span>            :           _DistanceType;
<span class="lineNum">    2547 </span>            : 
<span class="lineNum">    2548 </span>            :       if (__first == __middle || __middle == __last)
<span class="lineNum">    2549 </span>            :         return;
<span class="lineNum">    2550 </span>            : 
<span class="lineNum">    2551 </span>            :       const _DistanceType __len1 = std::distance(__first, __middle);
<span class="lineNum">    2552 </span>            :       const _DistanceType __len2 = std::distance(__middle, __last);
<span class="lineNum">    2553 </span>            : 
<span class="lineNum">    2554 </span>            :       typedef _Temporary_buffer&lt;_BidirectionalIterator, _ValueType&gt; _TmpBuf;
<span class="lineNum">    2555 </span>            :       _TmpBuf __buf(__first, __last);
<span class="lineNum">    2556 </span>            : 
<span class="lineNum">    2557 </span>            :       if (__buf.begin() == 0)
<span class="lineNum">    2558 </span>            :         std::__merge_without_buffer
<span class="lineNum">    2559 </span>            :           (__first, __middle, __last, __len1, __len2, __comp);
<span class="lineNum">    2560 </span>            :       else
<span class="lineNum">    2561 </span>            :         std::__merge_adaptive
<span class="lineNum">    2562 </span>            :           (__first, __middle, __last, __len1, __len2, __buf.begin(),
<span class="lineNum">    2563 </span>            :            _DistanceType(__buf.size()), __comp);
<span class="lineNum">    2564 </span>            :     }
<span class="lineNum">    2565 </span>            : 
<span class="lineNum">    2566 </span>            :   /**
<span class="lineNum">    2567 </span>            :    *  @brief Merges two sorted ranges in place.
<span class="lineNum">    2568 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    2569 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2570 </span>            :    *  @param  __middle  Another iterator.
<span class="lineNum">    2571 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2572 </span>            :    *  @return  Nothing.
<span class="lineNum">    2573 </span>            :    *
<span class="lineNum">    2574 </span>            :    *  Merges two sorted and consecutive ranges, [__first,__middle) and
<span class="lineNum">    2575 </span>            :    *  [__middle,__last), and puts the result in [__first,__last).  The
<span class="lineNum">    2576 </span>            :    *  output will be sorted.  The sort is @e stable, that is, for
<span class="lineNum">    2577 </span>            :    *  equivalent elements in the two ranges, elements from the first
<span class="lineNum">    2578 </span>            :    *  range will always come before elements from the second.
<span class="lineNum">    2579 </span>            :    *
<span class="lineNum">    2580 </span>            :    *  If enough additional memory is available, this takes (__last-__first)-1
<span class="lineNum">    2581 </span>            :    *  comparisons.  Otherwise an NlogN algorithm is used, where N is
<span class="lineNum">    2582 </span>            :    *  distance(__first,__last).
<span class="lineNum">    2583 </span>            :   */
<span class="lineNum">    2584 </span>            :   template&lt;typename _BidirectionalIterator&gt;
<span class="lineNum">    2585 </span>            :     inline void
<span class="lineNum">    2586 </span>            :     inplace_merge(_BidirectionalIterator __first,
<span class="lineNum">    2587 </span>            :                   _BidirectionalIterator __middle,
<span class="lineNum">    2588 </span>            :                   _BidirectionalIterator __last)
<span class="lineNum">    2589 </span>            :     {
<span class="lineNum">    2590 </span>            :       // concept requirements
<span class="lineNum">    2591 </span>            :       __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept&lt;
<span class="lineNum">    2592 </span>            :             _BidirectionalIterator&gt;)
<span class="lineNum">    2593 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    2594 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type&gt;)
<span class="lineNum">    2595 </span>            :       __glibcxx_requires_sorted(__first, __middle);
<span class="lineNum">    2596 </span>            :       __glibcxx_requires_sorted(__middle, __last);
<span class="lineNum">    2597 </span>            : 
<span class="lineNum">    2598 </span>            :       std::__inplace_merge(__first, __middle, __last,
<span class="lineNum">    2599 </span>            :                            __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    2600 </span>            :     }
<span class="lineNum">    2601 </span>            : 
<span class="lineNum">    2602 </span>            :   /**
<span class="lineNum">    2603 </span>            :    *  @brief Merges two sorted ranges in place.
<span class="lineNum">    2604 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    2605 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    2606 </span>            :    *  @param  __middle  Another iterator.
<span class="lineNum">    2607 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    2608 </span>            :    *  @param  __comp    A functor to use for comparisons.
<span class="lineNum">    2609 </span>            :    *  @return  Nothing.
<span class="lineNum">    2610 </span>            :    *
<span class="lineNum">    2611 </span>            :    *  Merges two sorted and consecutive ranges, [__first,__middle) and
<span class="lineNum">    2612 </span>            :    *  [middle,last), and puts the result in [__first,__last).  The output will
<span class="lineNum">    2613 </span>            :    *  be sorted.  The sort is @e stable, that is, for equivalent
<span class="lineNum">    2614 </span>            :    *  elements in the two ranges, elements from the first range will always
<span class="lineNum">    2615 </span>            :    *  come before elements from the second.
<span class="lineNum">    2616 </span>            :    *
<span class="lineNum">    2617 </span>            :    *  If enough additional memory is available, this takes (__last-__first)-1
<span class="lineNum">    2618 </span>            :    *  comparisons.  Otherwise an NlogN algorithm is used, where N is
<span class="lineNum">    2619 </span>            :    *  distance(__first,__last).
<span class="lineNum">    2620 </span>            :    *
<span class="lineNum">    2621 </span>            :    *  The comparison function should have the same effects on ordering as
<span class="lineNum">    2622 </span>            :    *  the function used for the initial sort.
<span class="lineNum">    2623 </span>            :   */
<span class="lineNum">    2624 </span>            :   template&lt;typename _BidirectionalIterator, typename _Compare&gt;
<span class="lineNum">    2625 </span>            :     inline void
<span class="lineNum">    2626 </span>            :     inplace_merge(_BidirectionalIterator __first,
<span class="lineNum">    2627 </span>            :                   _BidirectionalIterator __middle,
<span class="lineNum">    2628 </span>            :                   _BidirectionalIterator __last,
<span class="lineNum">    2629 </span>            :                   _Compare __comp)
<span class="lineNum">    2630 </span>            :     {
<span class="lineNum">    2631 </span>            :       // concept requirements
<span class="lineNum">    2632 </span>            :       __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept&lt;
<span class="lineNum">    2633 </span>            :             _BidirectionalIterator&gt;)
<span class="lineNum">    2634 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2635 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type,
<span class="lineNum">    2636 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type&gt;)
<span class="lineNum">    2637 </span>            :       __glibcxx_requires_sorted_pred(__first, __middle, __comp);
<span class="lineNum">    2638 </span>            :       __glibcxx_requires_sorted_pred(__middle, __last, __comp);
<span class="lineNum">    2639 </span>            : 
<span class="lineNum">    2640 </span>            :       std::__inplace_merge(__first, __middle, __last,
<span class="lineNum">    2641 </span>            :                            __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    2642 </span>            :     }
<span class="lineNum">    2643 </span>            : 
<span class="lineNum">    2644 </span>            : 
<span class="lineNum">    2645 </span>            :   /// This is a helper function for the __merge_sort_loop routines.
<span class="lineNum">    2646 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">    2647 </span>            :            typename _Compare&gt;
<span class="lineNum">    2648 </span>            :     _OutputIterator
<span class="lineNum">    2649 </span>            :     __move_merge(_InputIterator __first1, _InputIterator __last1,
<span class="lineNum">    2650 </span>            :                  _InputIterator __first2, _InputIterator __last2,
<span class="lineNum">    2651 </span>            :                  _OutputIterator __result, _Compare __comp)
<span class="lineNum">    2652 </span>            :     {
<span class="lineNum">    2653 </span>            :       while (__first1 != __last1 &amp;&amp; __first2 != __last2)
<span class="lineNum">    2654 </span>            :         {
<span class="lineNum">    2655 </span>            :           if (__comp(__first2, __first1))
<span class="lineNum">    2656 </span>            :             {
<span class="lineNum">    2657 </span>            :               *__result = _GLIBCXX_MOVE(*__first2);
<span class="lineNum">    2658 </span>            :               ++__first2;
<span class="lineNum">    2659 </span>            :             }
<span class="lineNum">    2660 </span>            :           else
<span class="lineNum">    2661 </span>            :             {
<span class="lineNum">    2662 </span>            :               *__result = _GLIBCXX_MOVE(*__first1);
<span class="lineNum">    2663 </span>            :               ++__first1;
<span class="lineNum">    2664 </span>            :             }
<span class="lineNum">    2665 </span>            :           ++__result;
<span class="lineNum">    2666 </span>            :         }
<span class="lineNum">    2667 </span>            :       return _GLIBCXX_MOVE3(__first2, __last2,
<span class="lineNum">    2668 </span>            :                             _GLIBCXX_MOVE3(__first1, __last1,
<span class="lineNum">    2669 </span>            :                                            __result));
<span class="lineNum">    2670 </span>            :     }
<span class="lineNum">    2671 </span>            : 
<span class="lineNum">    2672 </span>            :   template&lt;typename _RandomAccessIterator1, typename _RandomAccessIterator2,
<span class="lineNum">    2673 </span>            :            typename _Distance, typename _Compare&gt;
<span class="lineNum">    2674 </span>            :     void
<span class="lineNum">    2675 </span>            :     __merge_sort_loop(_RandomAccessIterator1 __first,
<span class="lineNum">    2676 </span>            :                       _RandomAccessIterator1 __last,
<span class="lineNum">    2677 </span>            :                       _RandomAccessIterator2 __result, _Distance __step_size,
<span class="lineNum">    2678 </span>            :                       _Compare __comp)
<span class="lineNum">    2679 </span>            :     {
<span class="lineNum">    2680 </span>            :       const _Distance __two_step = 2 * __step_size;
<span class="lineNum">    2681 </span>            : 
<span class="lineNum">    2682 </span>            :       while (__last - __first &gt;= __two_step)
<span class="lineNum">    2683 </span>            :         {
<span class="lineNum">    2684 </span>            :           __result = std::__move_merge(__first, __first + __step_size,
<span class="lineNum">    2685 </span>            :                                        __first + __step_size,
<span class="lineNum">    2686 </span>            :                                        __first + __two_step,
<span class="lineNum">    2687 </span>            :                                        __result, __comp);
<span class="lineNum">    2688 </span>            :           __first += __two_step;
<span class="lineNum">    2689 </span>            :         }
<span class="lineNum">    2690 </span>            :       __step_size = std::min(_Distance(__last - __first), __step_size);
<span class="lineNum">    2691 </span>            : 
<span class="lineNum">    2692 </span>            :       std::__move_merge(__first, __first + __step_size,
<span class="lineNum">    2693 </span>            :                         __first + __step_size, __last, __result, __comp);
<span class="lineNum">    2694 </span>            :     }
<span class="lineNum">    2695 </span>            : 
<span class="lineNum">    2696 </span>            :   template&lt;typename _RandomAccessIterator, typename _Distance,
<span class="lineNum">    2697 </span>            :            typename _Compare&gt;
<span class="lineNum">    2698 </span>            :     void
<span class="lineNum">    2699 </span>            :     __chunk_insertion_sort(_RandomAccessIterator __first,
<span class="lineNum">    2700 </span>            :                            _RandomAccessIterator __last,
<span class="lineNum">    2701 </span>            :                            _Distance __chunk_size, _Compare __comp)
<span class="lineNum">    2702 </span>            :     {
<span class="lineNum">    2703 </span>            :       while (__last - __first &gt;= __chunk_size)
<span class="lineNum">    2704 </span>            :         {
<span class="lineNum">    2705 </span>            :           std::__insertion_sort(__first, __first + __chunk_size, __comp);
<span class="lineNum">    2706 </span>            :           __first += __chunk_size;
<span class="lineNum">    2707 </span>            :         }
<span class="lineNum">    2708 </span>            :       std::__insertion_sort(__first, __last, __comp);
<span class="lineNum">    2709 </span>            :     }
<span class="lineNum">    2710 </span>            : 
<span class="lineNum">    2711 </span>            :   enum { _S_chunk_size = 7 };
<span class="lineNum">    2712 </span>            : 
<span class="lineNum">    2713 </span>            :   template&lt;typename _RandomAccessIterator, typename _Pointer, typename _Compare&gt;
<span class="lineNum">    2714 </span>            :     void
<span class="lineNum">    2715 </span>            :     __merge_sort_with_buffer(_RandomAccessIterator __first,
<span class="lineNum">    2716 </span>            :                              _RandomAccessIterator __last,
<span class="lineNum">    2717 </span>            :                              _Pointer __buffer, _Compare __comp)
<span class="lineNum">    2718 </span>            :     {
<span class="lineNum">    2719 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::difference_type
<span class="lineNum">    2720 </span>            :         _Distance;
<span class="lineNum">    2721 </span>            : 
<span class="lineNum">    2722 </span>            :       const _Distance __len = __last - __first;
<span class="lineNum">    2723 </span>            :       const _Pointer __buffer_last = __buffer + __len;
<span class="lineNum">    2724 </span>            : 
<span class="lineNum">    2725 </span>            :       _Distance __step_size = _S_chunk_size;
<span class="lineNum">    2726 </span>            :       std::__chunk_insertion_sort(__first, __last, __step_size, __comp);
<span class="lineNum">    2727 </span>            : 
<span class="lineNum">    2728 </span>            :       while (__step_size &lt; __len)
<span class="lineNum">    2729 </span>            :         {
<span class="lineNum">    2730 </span>            :           std::__merge_sort_loop(__first, __last, __buffer,
<span class="lineNum">    2731 </span>            :                                  __step_size, __comp);
<span class="lineNum">    2732 </span>            :           __step_size *= 2;
<span class="lineNum">    2733 </span>            :           std::__merge_sort_loop(__buffer, __buffer_last, __first,
<span class="lineNum">    2734 </span>            :                                  __step_size, __comp);
<span class="lineNum">    2735 </span>            :           __step_size *= 2;
<span class="lineNum">    2736 </span>            :         }
<span class="lineNum">    2737 </span>            :     }
<span class="lineNum">    2738 </span>            : 
<span class="lineNum">    2739 </span>            :   template&lt;typename _RandomAccessIterator, typename _Pointer,
<span class="lineNum">    2740 </span>            :            typename _Distance, typename _Compare&gt;
<span class="lineNum">    2741 </span>            :     void
<span class="lineNum">    2742 </span>            :     __stable_sort_adaptive(_RandomAccessIterator __first,
<span class="lineNum">    2743 </span>            :                            _RandomAccessIterator __last,
<span class="lineNum">    2744 </span>            :                            _Pointer __buffer, _Distance __buffer_size,
<span class="lineNum">    2745 </span>            :                            _Compare __comp)
<span class="lineNum">    2746 </span>            :     {
<span class="lineNum">    2747 </span>            :       const _Distance __len = (__last - __first + 1) / 2;
<span class="lineNum">    2748 </span>            :       const _RandomAccessIterator __middle = __first + __len;
<span class="lineNum">    2749 </span>            :       if (__len &gt; __buffer_size)
<span class="lineNum">    2750 </span>            :         {
<span class="lineNum">    2751 </span>            :           std::__stable_sort_adaptive(__first, __middle, __buffer,
<span class="lineNum">    2752 </span>            :                                       __buffer_size, __comp);
<span class="lineNum">    2753 </span>            :           std::__stable_sort_adaptive(__middle, __last, __buffer,
<span class="lineNum">    2754 </span>            :                                       __buffer_size, __comp);
<span class="lineNum">    2755 </span>            :         }
<span class="lineNum">    2756 </span>            :       else
<span class="lineNum">    2757 </span>            :         {
<span class="lineNum">    2758 </span>            :           std::__merge_sort_with_buffer(__first, __middle, __buffer, __comp);
<span class="lineNum">    2759 </span>            :           std::__merge_sort_with_buffer(__middle, __last, __buffer, __comp);
<span class="lineNum">    2760 </span>            :         }
<span class="lineNum">    2761 </span>            :       std::__merge_adaptive(__first, __middle, __last,
<span class="lineNum">    2762 </span>            :                             _Distance(__middle - __first),
<span class="lineNum">    2763 </span>            :                             _Distance(__last - __middle),
<span class="lineNum">    2764 </span>            :                             __buffer, __buffer_size,
<span class="lineNum">    2765 </span>            :                             __comp);
<span class="lineNum">    2766 </span>            :     }
<span class="lineNum">    2767 </span>            : 
<span class="lineNum">    2768 </span>            :   /// This is a helper function for the stable sorting routines.
<span class="lineNum">    2769 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;
<span class="lineNum">    2770 </span>            :     void
<span class="lineNum">    2771 </span>            :     __inplace_stable_sort(_RandomAccessIterator __first,
<span class="lineNum">    2772 </span>            :                           _RandomAccessIterator __last, _Compare __comp)
<span class="lineNum">    2773 </span>            :     {
<span class="lineNum">    2774 </span>            :       if (__last - __first &lt; 15)
<span class="lineNum">    2775 </span>            :         {
<span class="lineNum">    2776 </span>            :           std::__insertion_sort(__first, __last, __comp);
<span class="lineNum">    2777 </span>            :           return;
<span class="lineNum">    2778 </span>            :         }
<span class="lineNum">    2779 </span>            :       _RandomAccessIterator __middle = __first + (__last - __first) / 2;
<span class="lineNum">    2780 </span>            :       std::__inplace_stable_sort(__first, __middle, __comp);
<span class="lineNum">    2781 </span>            :       std::__inplace_stable_sort(__middle, __last, __comp);
<span class="lineNum">    2782 </span>            :       std::__merge_without_buffer(__first, __middle, __last,
<span class="lineNum">    2783 </span>            :                                   __middle - __first,
<span class="lineNum">    2784 </span>            :                                   __last - __middle,
<span class="lineNum">    2785 </span>            :                                   __comp);
<span class="lineNum">    2786 </span>            :     }
<span class="lineNum">    2787 </span>            : 
<span class="lineNum">    2788 </span>            :   // stable_sort
<span class="lineNum">    2789 </span>            : 
<span class="lineNum">    2790 </span>            :   // Set algorithms: includes, set_union, set_intersection, set_difference,
<span class="lineNum">    2791 </span>            :   // set_symmetric_difference.  All of these algorithms have the precondition
<span class="lineNum">    2792 </span>            :   // that their input ranges are sorted and the postcondition that their output
<span class="lineNum">    2793 </span>            :   // ranges are sorted.
<span class="lineNum">    2794 </span>            : 
<span class="lineNum">    2795 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    2796 </span>            :            typename _Compare&gt;
<span class="lineNum">    2797 </span>            :     bool
<span class="lineNum">    2798 </span>            :     __includes(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    2799 </span>            :                _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    2800 </span>            :                _Compare __comp)
<span class="lineNum">    2801 </span>            :     {
<span class="lineNum">    2802 </span>            :       while (__first1 != __last1 &amp;&amp; __first2 != __last2)
<span class="lineNum">    2803 </span>            :         if (__comp(__first2, __first1))
<span class="lineNum">    2804 </span>            :           return false;
<span class="lineNum">    2805 </span>            :         else if (__comp(__first1, __first2))
<span class="lineNum">    2806 </span>            :           ++__first1;
<span class="lineNum">    2807 </span>            :         else
<span class="lineNum">    2808 </span>            :           ++__first1, ++__first2;
<span class="lineNum">    2809 </span>            : 
<span class="lineNum">    2810 </span>            :       return __first2 == __last2;
<span class="lineNum">    2811 </span>            :     }
<span class="lineNum">    2812 </span>            : 
<span class="lineNum">    2813 </span>            :   /**
<span class="lineNum">    2814 </span>            :    *  @brief Determines whether all elements of a sequence exists in a range.
<span class="lineNum">    2815 </span>            :    *  @param  __first1  Start of search range.
<span class="lineNum">    2816 </span>            :    *  @param  __last1   End of search range.
<span class="lineNum">    2817 </span>            :    *  @param  __first2  Start of sequence
<span class="lineNum">    2818 </span>            :    *  @param  __last2   End of sequence.
<span class="lineNum">    2819 </span>            :    *  @return  True if each element in [__first2,__last2) is contained in order
<span class="lineNum">    2820 </span>            :    *  within [__first1,__last1).  False otherwise.
<span class="lineNum">    2821 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    2822 </span>            :    *
<span class="lineNum">    2823 </span>            :    *  This operation expects both [__first1,__last1) and
<span class="lineNum">    2824 </span>            :    *  [__first2,__last2) to be sorted.  Searches for the presence of
<span class="lineNum">    2825 </span>            :    *  each element in [__first2,__last2) within [__first1,__last1).
<span class="lineNum">    2826 </span>            :    *  The iterators over each range only move forward, so this is a
<span class="lineNum">    2827 </span>            :    *  linear algorithm.  If an element in [__first2,__last2) is not
<span class="lineNum">    2828 </span>            :    *  found before the search iterator reaches @p __last2, false is
<span class="lineNum">    2829 </span>            :    *  returned.
<span class="lineNum">    2830 </span>            :   */
<span class="lineNum">    2831 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2&gt;
<span class="lineNum">    2832 </span>            :     inline bool
<span class="lineNum">    2833 </span>            :     includes(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    2834 </span>            :              _InputIterator2 __first2, _InputIterator2 __last2)
<span class="lineNum">    2835 </span>            :     {
<span class="lineNum">    2836 </span>            :       // concept requirements
<span class="lineNum">    2837 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    2838 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    2839 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    2840 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    2841 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    2842 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    2843 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    2844 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    2845 </span>            :       __glibcxx_requires_sorted_set(__first1, __last1, __first2);
<span class="lineNum">    2846 </span>            :       __glibcxx_requires_sorted_set(__first2, __last2, __first1);
<span class="lineNum">    2847 </span>            : 
<span class="lineNum">    2848 </span>            :       return std::__includes(__first1, __last1, __first2, __last2,
<span class="lineNum">    2849 </span>            :                              __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    2850 </span>            :     }
<span class="lineNum">    2851 </span>            : 
<span class="lineNum">    2852 </span>            :   /**
<span class="lineNum">    2853 </span>            :    *  @brief Determines whether all elements of a sequence exists in a range
<span class="lineNum">    2854 </span>            :    *  using comparison.
<span class="lineNum">    2855 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    2856 </span>            :    *  @param  __first1  Start of search range.
<span class="lineNum">    2857 </span>            :    *  @param  __last1   End of search range.
<span class="lineNum">    2858 </span>            :    *  @param  __first2  Start of sequence
<span class="lineNum">    2859 </span>            :    *  @param  __last2   End of sequence.
<span class="lineNum">    2860 </span>            :    *  @param  __comp    Comparison function to use.
<span class="lineNum">    2861 </span>            :    *  @return True if each element in [__first2,__last2) is contained
<span class="lineNum">    2862 </span>            :    *  in order within [__first1,__last1) according to comp.  False
<span class="lineNum">    2863 </span>            :    *  otherwise.  @ingroup set_algorithms
<span class="lineNum">    2864 </span>            :    *
<span class="lineNum">    2865 </span>            :    *  This operation expects both [__first1,__last1) and
<span class="lineNum">    2866 </span>            :    *  [__first2,__last2) to be sorted.  Searches for the presence of
<span class="lineNum">    2867 </span>            :    *  each element in [__first2,__last2) within [__first1,__last1),
<span class="lineNum">    2868 </span>            :    *  using comp to decide.  The iterators over each range only move
<span class="lineNum">    2869 </span>            :    *  forward, so this is a linear algorithm.  If an element in
<span class="lineNum">    2870 </span>            :    *  [__first2,__last2) is not found before the search iterator
<span class="lineNum">    2871 </span>            :    *  reaches @p __last2, false is returned.
<span class="lineNum">    2872 </span>            :   */
<span class="lineNum">    2873 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    2874 </span>            :            typename _Compare&gt;
<span class="lineNum">    2875 </span>            :     inline bool
<span class="lineNum">    2876 </span>            :     includes(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    2877 </span>            :              _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    2878 </span>            :              _Compare __comp)
<span class="lineNum">    2879 </span>            :     {
<span class="lineNum">    2880 </span>            :       // concept requirements
<span class="lineNum">    2881 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    2882 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    2883 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2884 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    2885 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    2886 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2887 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    2888 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    2889 </span>            :       __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
<span class="lineNum">    2890 </span>            :       __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
<span class="lineNum">    2891 </span>            : 
<span class="lineNum">    2892 </span>            :       return std::__includes(__first1, __last1, __first2, __last2,
<span class="lineNum">    2893 </span>            :                              __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    2894 </span>            :     }
<span class="lineNum">    2895 </span>            : 
<span class="lineNum">    2896 </span>            :   // nth_element
<span class="lineNum">    2897 </span>            :   // merge
<span class="lineNum">    2898 </span>            :   // set_difference
<span class="lineNum">    2899 </span>            :   // set_intersection
<span class="lineNum">    2900 </span>            :   // set_union
<span class="lineNum">    2901 </span>            :   // stable_sort
<span class="lineNum">    2902 </span>            :   // set_symmetric_difference
<span class="lineNum">    2903 </span>            :   // min_element
<span class="lineNum">    2904 </span>            :   // max_element
<span class="lineNum">    2905 </span>            : 
<span class="lineNum">    2906 </span>            :   template&lt;typename _BidirectionalIterator, typename _Compare&gt;
<span class="lineNum">    2907 </span>            :     bool
<span class="lineNum">    2908 </span>            :     __next_permutation(_BidirectionalIterator __first,
<span class="lineNum">    2909 </span>            :                        _BidirectionalIterator __last, _Compare __comp)
<span class="lineNum">    2910 </span>            :     {
<span class="lineNum">    2911 </span>            :       if (__first == __last)
<span class="lineNum">    2912 </span>            :         return false;
<span class="lineNum">    2913 </span>            :       _BidirectionalIterator __i = __first;
<span class="lineNum">    2914 </span>            :       ++__i;
<span class="lineNum">    2915 </span>            :       if (__i == __last)
<span class="lineNum">    2916 </span>            :         return false;
<span class="lineNum">    2917 </span>            :       __i = __last;
<span class="lineNum">    2918 </span>            :       --__i;
<span class="lineNum">    2919 </span>            : 
<span class="lineNum">    2920 </span>            :       for(;;)
<span class="lineNum">    2921 </span>            :         {
<span class="lineNum">    2922 </span>            :           _BidirectionalIterator __ii = __i;
<span class="lineNum">    2923 </span>            :           --__i;
<span class="lineNum">    2924 </span>            :           if (__comp(__i, __ii))
<span class="lineNum">    2925 </span>            :             {
<span class="lineNum">    2926 </span>            :               _BidirectionalIterator __j = __last;
<span class="lineNum">    2927 </span>            :               while (!__comp(__i, --__j))
<span class="lineNum">    2928 </span>            :                 {}
<span class="lineNum">    2929 </span>            :               std::iter_swap(__i, __j);
<span class="lineNum">    2930 </span>            :               std::__reverse(__ii, __last,
<span class="lineNum">    2931 </span>            :                              std::__iterator_category(__first));
<span class="lineNum">    2932 </span>            :               return true;
<span class="lineNum">    2933 </span>            :             }
<span class="lineNum">    2934 </span>            :           if (__i == __first)
<span class="lineNum">    2935 </span>            :             {
<span class="lineNum">    2936 </span>            :               std::__reverse(__first, __last,
<span class="lineNum">    2937 </span>            :                              std::__iterator_category(__first));
<span class="lineNum">    2938 </span>            :               return false;
<span class="lineNum">    2939 </span>            :             }
<span class="lineNum">    2940 </span>            :         }
<span class="lineNum">    2941 </span>            :     }
<span class="lineNum">    2942 </span>            : 
<span class="lineNum">    2943 </span>            :   /**
<span class="lineNum">    2944 </span>            :    *  @brief  Permute range into the next @e dictionary ordering.
<span class="lineNum">    2945 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    2946 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    2947 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    2948 </span>            :    *  @return  False if wrapped to first permutation, true otherwise.
<span class="lineNum">    2949 </span>            :    *
<span class="lineNum">    2950 </span>            :    *  Treats all permutations of the range as a set of @e dictionary sorted
<span class="lineNum">    2951 </span>            :    *  sequences.  Permutes the current sequence into the next one of this set.
<span class="lineNum">    2952 </span>            :    *  Returns true if there are more sequences to generate.  If the sequence
<span class="lineNum">    2953 </span>            :    *  is the largest of the set, the smallest is generated and false returned.
<span class="lineNum">    2954 </span>            :   */
<span class="lineNum">    2955 </span>            :   template&lt;typename _BidirectionalIterator&gt;
<span class="lineNum">    2956 </span>            :     inline bool
<span class="lineNum">    2957 </span>            :     next_permutation(_BidirectionalIterator __first,
<span class="lineNum">    2958 </span>            :                      _BidirectionalIterator __last)
<span class="lineNum">    2959 </span>            :     {
<span class="lineNum">    2960 </span>            :       // concept requirements
<span class="lineNum">    2961 </span>            :       __glibcxx_function_requires(_BidirectionalIteratorConcept&lt;
<span class="lineNum">    2962 </span>            :                                   _BidirectionalIterator&gt;)
<span class="lineNum">    2963 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    2964 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type&gt;)
<span class="lineNum">    2965 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    2966 </span>            : 
<span class="lineNum">    2967 </span>            :       return std::__next_permutation
<span class="lineNum">    2968 </span>            :         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    2969 </span>            :     }
<span class="lineNum">    2970 </span>            : 
<span class="lineNum">    2971 </span>            :   /**
<span class="lineNum">    2972 </span>            :    *  @brief  Permute range into the next @e dictionary ordering using
<span class="lineNum">    2973 </span>            :    *          comparison functor.
<span class="lineNum">    2974 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    2975 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    2976 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    2977 </span>            :    *  @param  __comp   A comparison functor.
<span class="lineNum">    2978 </span>            :    *  @return  False if wrapped to first permutation, true otherwise.
<span class="lineNum">    2979 </span>            :    *
<span class="lineNum">    2980 </span>            :    *  Treats all permutations of the range [__first,__last) as a set of
<span class="lineNum">    2981 </span>            :    *  @e dictionary sorted sequences ordered by @p __comp.  Permutes the current
<span class="lineNum">    2982 </span>            :    *  sequence into the next one of this set.  Returns true if there are more
<span class="lineNum">    2983 </span>            :    *  sequences to generate.  If the sequence is the largest of the set, the
<span class="lineNum">    2984 </span>            :    *  smallest is generated and false returned.
<span class="lineNum">    2985 </span>            :   */
<span class="lineNum">    2986 </span>            :   template&lt;typename _BidirectionalIterator, typename _Compare&gt;
<span class="lineNum">    2987 </span>            :     inline bool
<span class="lineNum">    2988 </span>            :     next_permutation(_BidirectionalIterator __first,
<span class="lineNum">    2989 </span>            :                      _BidirectionalIterator __last, _Compare __comp)
<span class="lineNum">    2990 </span>            :     {
<span class="lineNum">    2991 </span>            :       // concept requirements
<span class="lineNum">    2992 </span>            :       __glibcxx_function_requires(_BidirectionalIteratorConcept&lt;
<span class="lineNum">    2993 </span>            :                                   _BidirectionalIterator&gt;)
<span class="lineNum">    2994 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    2995 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type,
<span class="lineNum">    2996 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type&gt;)
<span class="lineNum">    2997 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    2998 </span>            : 
<span class="lineNum">    2999 </span>            :       return std::__next_permutation
<span class="lineNum">    3000 </span>            :         (__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    3001 </span>            :     }
<span class="lineNum">    3002 </span>            : 
<span class="lineNum">    3003 </span>            :   template&lt;typename _BidirectionalIterator, typename _Compare&gt;
<span class="lineNum">    3004 </span>            :     bool
<span class="lineNum">    3005 </span>            :     __prev_permutation(_BidirectionalIterator __first,
<span class="lineNum">    3006 </span>            :                        _BidirectionalIterator __last, _Compare __comp)
<span class="lineNum">    3007 </span>            :     {
<span class="lineNum">    3008 </span>            :       if (__first == __last)
<span class="lineNum">    3009 </span>            :         return false;
<span class="lineNum">    3010 </span>            :       _BidirectionalIterator __i = __first;
<span class="lineNum">    3011 </span>            :       ++__i;
<span class="lineNum">    3012 </span>            :       if (__i == __last)
<span class="lineNum">    3013 </span>            :         return false;
<span class="lineNum">    3014 </span>            :       __i = __last;
<span class="lineNum">    3015 </span>            :       --__i;
<span class="lineNum">    3016 </span>            : 
<span class="lineNum">    3017 </span>            :       for(;;)
<span class="lineNum">    3018 </span>            :         {
<span class="lineNum">    3019 </span>            :           _BidirectionalIterator __ii = __i;
<span class="lineNum">    3020 </span>            :           --__i;
<span class="lineNum">    3021 </span>            :           if (__comp(__ii, __i))
<span class="lineNum">    3022 </span>            :             {
<span class="lineNum">    3023 </span>            :               _BidirectionalIterator __j = __last;
<span class="lineNum">    3024 </span>            :               while (!__comp(--__j, __i))
<span class="lineNum">    3025 </span>            :                 {}
<span class="lineNum">    3026 </span>            :               std::iter_swap(__i, __j);
<span class="lineNum">    3027 </span>            :               std::__reverse(__ii, __last,
<span class="lineNum">    3028 </span>            :                              std::__iterator_category(__first));
<span class="lineNum">    3029 </span>            :               return true;
<span class="lineNum">    3030 </span>            :             }
<span class="lineNum">    3031 </span>            :           if (__i == __first)
<span class="lineNum">    3032 </span>            :             {
<span class="lineNum">    3033 </span>            :               std::__reverse(__first, __last,
<span class="lineNum">    3034 </span>            :                              std::__iterator_category(__first));
<span class="lineNum">    3035 </span>            :               return false;
<span class="lineNum">    3036 </span>            :             }
<span class="lineNum">    3037 </span>            :         }
<span class="lineNum">    3038 </span>            :     }
<span class="lineNum">    3039 </span>            : 
<span class="lineNum">    3040 </span>            :   /**
<span class="lineNum">    3041 </span>            :    *  @brief  Permute range into the previous @e dictionary ordering.
<span class="lineNum">    3042 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3043 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    3044 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    3045 </span>            :    *  @return  False if wrapped to last permutation, true otherwise.
<span class="lineNum">    3046 </span>            :    *
<span class="lineNum">    3047 </span>            :    *  Treats all permutations of the range as a set of @e dictionary sorted
<span class="lineNum">    3048 </span>            :    *  sequences.  Permutes the current sequence into the previous one of this
<span class="lineNum">    3049 </span>            :    *  set.  Returns true if there are more sequences to generate.  If the
<span class="lineNum">    3050 </span>            :    *  sequence is the smallest of the set, the largest is generated and false
<span class="lineNum">    3051 </span>            :    *  returned.
<span class="lineNum">    3052 </span>            :   */
<span class="lineNum">    3053 </span>            :   template&lt;typename _BidirectionalIterator&gt;
<span class="lineNum">    3054 </span>            :     inline bool
<span class="lineNum">    3055 </span>            :     prev_permutation(_BidirectionalIterator __first,
<span class="lineNum">    3056 </span>            :                      _BidirectionalIterator __last)
<span class="lineNum">    3057 </span>            :     {
<span class="lineNum">    3058 </span>            :       // concept requirements
<span class="lineNum">    3059 </span>            :       __glibcxx_function_requires(_BidirectionalIteratorConcept&lt;
<span class="lineNum">    3060 </span>            :                                   _BidirectionalIterator&gt;)
<span class="lineNum">    3061 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    3062 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type&gt;)
<span class="lineNum">    3063 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3064 </span>            : 
<span class="lineNum">    3065 </span>            :       return std::__prev_permutation(__first, __last,
<span class="lineNum">    3066 </span>            :                                      __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    3067 </span>            :     }
<span class="lineNum">    3068 </span>            : 
<span class="lineNum">    3069 </span>            :   /**
<span class="lineNum">    3070 </span>            :    *  @brief  Permute range into the previous @e dictionary ordering using
<span class="lineNum">    3071 </span>            :    *          comparison functor.
<span class="lineNum">    3072 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3073 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    3074 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    3075 </span>            :    *  @param  __comp   A comparison functor.
<span class="lineNum">    3076 </span>            :    *  @return  False if wrapped to last permutation, true otherwise.
<span class="lineNum">    3077 </span>            :    *
<span class="lineNum">    3078 </span>            :    *  Treats all permutations of the range [__first,__last) as a set of
<span class="lineNum">    3079 </span>            :    *  @e dictionary sorted sequences ordered by @p __comp.  Permutes the current
<span class="lineNum">    3080 </span>            :    *  sequence into the previous one of this set.  Returns true if there are
<span class="lineNum">    3081 </span>            :    *  more sequences to generate.  If the sequence is the smallest of the set,
<span class="lineNum">    3082 </span>            :    *  the largest is generated and false returned.
<span class="lineNum">    3083 </span>            :   */
<span class="lineNum">    3084 </span>            :   template&lt;typename _BidirectionalIterator, typename _Compare&gt;
<span class="lineNum">    3085 </span>            :     inline bool
<span class="lineNum">    3086 </span>            :     prev_permutation(_BidirectionalIterator __first,
<span class="lineNum">    3087 </span>            :                      _BidirectionalIterator __last, _Compare __comp)
<span class="lineNum">    3088 </span>            :     {
<span class="lineNum">    3089 </span>            :       // concept requirements
<span class="lineNum">    3090 </span>            :       __glibcxx_function_requires(_BidirectionalIteratorConcept&lt;
<span class="lineNum">    3091 </span>            :                                   _BidirectionalIterator&gt;)
<span class="lineNum">    3092 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    3093 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type,
<span class="lineNum">    3094 </span>            :             typename iterator_traits&lt;_BidirectionalIterator&gt;::value_type&gt;)
<span class="lineNum">    3095 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3096 </span>            : 
<span class="lineNum">    3097 </span>            :       return std::__prev_permutation(__first, __last,
<span class="lineNum">    3098 </span>            :                                 __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    3099 </span>            :     }
<span class="lineNum">    3100 </span>            : 
<span class="lineNum">    3101 </span>            :   // replace
<span class="lineNum">    3102 </span>            :   // replace_if
<span class="lineNum">    3103 </span>            : 
<span class="lineNum">    3104 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">    3105 </span>            :            typename _Predicate, typename _Tp&gt;
<span class="lineNum">    3106 </span>            :     _OutputIterator
<span class="lineNum">    3107 </span>            :     __replace_copy_if(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    3108 </span>            :                       _OutputIterator __result,
<span class="lineNum">    3109 </span>            :                       _Predicate __pred, const _Tp&amp; __new_value)
<span class="lineNum">    3110 </span>            :     {
<span class="lineNum">    3111 </span>            :       for (; __first != __last; ++__first, ++__result)
<span class="lineNum">    3112 </span>            :         if (__pred(__first))
<span class="lineNum">    3113 </span>            :           *__result = __new_value;
<span class="lineNum">    3114 </span>            :         else
<span class="lineNum">    3115 </span>            :           *__result = *__first;
<span class="lineNum">    3116 </span>            :       return __result;
<span class="lineNum">    3117 </span>            :     }
<span class="lineNum">    3118 </span>            : 
<span class="lineNum">    3119 </span>            :   /**
<span class="lineNum">    3120 </span>            :    *  @brief Copy a sequence, replacing each element of one value with another
<span class="lineNum">    3121 </span>            :    *         value.
<span class="lineNum">    3122 </span>            :    *  @param  __first      An input iterator.
<span class="lineNum">    3123 </span>            :    *  @param  __last       An input iterator.
<span class="lineNum">    3124 </span>            :    *  @param  __result     An output iterator.
<span class="lineNum">    3125 </span>            :    *  @param  __old_value  The value to be replaced.
<span class="lineNum">    3126 </span>            :    *  @param  __new_value  The replacement value.
<span class="lineNum">    3127 </span>            :    *  @return   The end of the output sequence, @p result+(last-first).
<span class="lineNum">    3128 </span>            :    *
<span class="lineNum">    3129 </span>            :    *  Copies each element in the input range @p [__first,__last) to the
<span class="lineNum">    3130 </span>            :    *  output range @p [__result,__result+(__last-__first)) replacing elements
<span class="lineNum">    3131 </span>            :    *  equal to @p __old_value with @p __new_value.
<span class="lineNum">    3132 </span>            :   */
<span class="lineNum">    3133 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator, typename _Tp&gt;
<span class="lineNum">    3134 </span>            :     inline _OutputIterator
<span class="lineNum">    3135 </span>            :     replace_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    3136 </span>            :                  _OutputIterator __result,
<span class="lineNum">    3137 </span>            :                  const _Tp&amp; __old_value, const _Tp&amp; __new_value)
<span class="lineNum">    3138 </span>            :     {
<span class="lineNum">    3139 </span>            :       // concept requirements
<span class="lineNum">    3140 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3141 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    3142 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    3143 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">    3144 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type, _Tp&gt;)
<span class="lineNum">    3145 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3146 </span>            : 
<span class="lineNum">    3147 </span>            :       return std::__replace_copy_if(__first, __last, __result,
<span class="lineNum">    3148 </span>            :                         __gnu_cxx::__ops::__iter_equals_val(__old_value),
<span class="lineNum">    3149 </span>            :                                               __new_value);
<span class="lineNum">    3150 </span>            :     }
<span class="lineNum">    3151 </span>            : 
<span class="lineNum">    3152 </span>            :   /**
<span class="lineNum">    3153 </span>            :    *  @brief Copy a sequence, replacing each value for which a predicate
<span class="lineNum">    3154 </span>            :    *         returns true with another value.
<span class="lineNum">    3155 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    3156 </span>            :    *  @param  __first      An input iterator.
<span class="lineNum">    3157 </span>            :    *  @param  __last       An input iterator.
<span class="lineNum">    3158 </span>            :    *  @param  __result     An output iterator.
<span class="lineNum">    3159 </span>            :    *  @param  __pred       A predicate.
<span class="lineNum">    3160 </span>            :    *  @param  __new_value  The replacement value.
<span class="lineNum">    3161 </span>            :    *  @return   The end of the output sequence, @p __result+(__last-__first).
<span class="lineNum">    3162 </span>            :    *
<span class="lineNum">    3163 </span>            :    *  Copies each element in the range @p [__first,__last) to the range
<span class="lineNum">    3164 </span>            :    *  @p [__result,__result+(__last-__first)) replacing elements for which
<span class="lineNum">    3165 </span>            :    *  @p __pred returns true with @p __new_value.
<span class="lineNum">    3166 </span>            :   */
<span class="lineNum">    3167 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">    3168 </span>            :            typename _Predicate, typename _Tp&gt;
<span class="lineNum">    3169 </span>            :     inline _OutputIterator
<span class="lineNum">    3170 </span>            :     replace_copy_if(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    3171 </span>            :                     _OutputIterator __result,
<span class="lineNum">    3172 </span>            :                     _Predicate __pred, const _Tp&amp; __new_value)
<span class="lineNum">    3173 </span>            :     {
<span class="lineNum">    3174 </span>            :       // concept requirements
<span class="lineNum">    3175 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3176 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    3177 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    3178 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">    3179 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    3180 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3181 </span>            : 
<span class="lineNum">    3182 </span>            :       return std::__replace_copy_if(__first, __last, __result,
<span class="lineNum">    3183 </span>            :                                 __gnu_cxx::__ops::__pred_iter(__pred),
<span class="lineNum">    3184 </span>            :                                               __new_value);
<span class="lineNum">    3185 </span>            :     }
<span class="lineNum">    3186 </span>            : 
<span class="lineNum">    3187 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">    3188 </span>            :     typename iterator_traits&lt;_InputIterator&gt;::difference_type
<span class="lineNum">    3189 </span>            :     __count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
<span class="lineNum">    3190 </span>            :     {
<span class="lineNum">    3191 </span>            :       typename iterator_traits&lt;_InputIterator&gt;::difference_type __n = 0;
<span class="lineNum">    3192 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">    3193 </span>            :         if (__pred(__first))
<span class="lineNum">    3194 </span>            :           ++__n;
<span class="lineNum">    3195 </span>            :       return __n;
<span class="lineNum">    3196 </span>            :     }
<span class="lineNum">    3197 </span>            : 
<span class="lineNum">    3198 </span>            : #if __cplusplus &gt;= 201103L
<span class="lineNum">    3199 </span>            :   /**
<span class="lineNum">    3200 </span>            :    *  @brief  Determines whether the elements of a sequence are sorted.
<span class="lineNum">    3201 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3202 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    3203 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    3204 </span>            :    *  @return  True if the elements are sorted, false otherwise.
<span class="lineNum">    3205 </span>            :   */
<span class="lineNum">    3206 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">    3207 </span>            :     inline bool
<span class="lineNum">    3208 </span>            :     is_sorted(_ForwardIterator __first, _ForwardIterator __last)
<span class="lineNum">    3209 </span>            :     { return std::is_sorted_until(__first, __last) == __last; }
<span class="lineNum">    3210 </span>            : 
<span class="lineNum">    3211 </span>            :   /**
<span class="lineNum">    3212 </span>            :    *  @brief  Determines whether the elements of a sequence are sorted
<span class="lineNum">    3213 </span>            :    *          according to a comparison functor.
<span class="lineNum">    3214 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3215 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    3216 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    3217 </span>            :    *  @param  __comp    A comparison functor.
<span class="lineNum">    3218 </span>            :    *  @return  True if the elements are sorted, false otherwise.
<span class="lineNum">    3219 </span>            :   */
<span class="lineNum">    3220 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    3221 </span>            :     inline bool
<span class="lineNum">    3222 </span>            :     is_sorted(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    3223 </span>            :               _Compare __comp)
<span class="lineNum">    3224 </span>            :     { return std::is_sorted_until(__first, __last, __comp) == __last; }
<span class="lineNum">    3225 </span>            : 
<span class="lineNum">    3226 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    3227 </span>            :     _ForwardIterator
<span class="lineNum">    3228 </span>            :     __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    3229 </span>            :                       _Compare __comp)
<span class="lineNum">    3230 </span>            :     {
<span class="lineNum">    3231 </span>            :       if (__first == __last)
<span class="lineNum">    3232 </span>            :         return __last;
<span class="lineNum">    3233 </span>            : 
<span class="lineNum">    3234 </span>            :       _ForwardIterator __next = __first;
<span class="lineNum">    3235 </span>            :       for (++__next; __next != __last; __first = __next, ++__next)
<span class="lineNum">    3236 </span>            :         if (__comp(__next, __first))
<span class="lineNum">    3237 </span>            :           return __next;
<span class="lineNum">    3238 </span>            :       return __next;
<span class="lineNum">    3239 </span>            :     }
<span class="lineNum">    3240 </span>            : 
<span class="lineNum">    3241 </span>            :   /**
<span class="lineNum">    3242 </span>            :    *  @brief  Determines the end of a sorted sequence.
<span class="lineNum">    3243 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3244 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    3245 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    3246 </span>            :    *  @return  An iterator pointing to the last iterator i in [__first, __last)
<span class="lineNum">    3247 </span>            :    *           for which the range [__first, i) is sorted.
<span class="lineNum">    3248 </span>            :   */
<span class="lineNum">    3249 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">    3250 </span>            :     inline _ForwardIterator
<span class="lineNum">    3251 </span>            :     is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
<span class="lineNum">    3252 </span>            :     {
<span class="lineNum">    3253 </span>            :       // concept requirements
<span class="lineNum">    3254 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    3255 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    3256 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    3257 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3258 </span>            : 
<span class="lineNum">    3259 </span>            :       return std::__is_sorted_until(__first, __last,
<span class="lineNum">    3260 </span>            :                                     __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    3261 </span>            :     }
<span class="lineNum">    3262 </span>            : 
<span class="lineNum">    3263 </span>            :   /**
<span class="lineNum">    3264 </span>            :    *  @brief  Determines the end of a sorted sequence using comparison functor.
<span class="lineNum">    3265 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3266 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    3267 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    3268 </span>            :    *  @param  __comp    A comparison functor.
<span class="lineNum">    3269 </span>            :    *  @return  An iterator pointing to the last iterator i in [__first, __last)
<span class="lineNum">    3270 </span>            :    *           for which the range [__first, i) is sorted.
<span class="lineNum">    3271 </span>            :   */
<span class="lineNum">    3272 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    3273 </span>            :     inline _ForwardIterator
<span class="lineNum">    3274 </span>            :     is_sorted_until(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    3275 </span>            :                     _Compare __comp)
<span class="lineNum">    3276 </span>            :     {
<span class="lineNum">    3277 </span>            :       // concept requirements
<span class="lineNum">    3278 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    3279 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    3280 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type,
<span class="lineNum">    3281 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    3282 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3283 </span>            : 
<span class="lineNum">    3284 </span>            :       return std::__is_sorted_until(__first, __last,
<span class="lineNum">    3285 </span>            :                                     __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    3286 </span>            :     }
<span class="lineNum">    3287 </span>            : 
<span class="lineNum">    3288 </span>            :   /**
<span class="lineNum">    3289 </span>            :    *  @brief  Determines min and max at once as an ordered pair.
<span class="lineNum">    3290 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3291 </span>            :    *  @param  __a  A thing of arbitrary type.
<span class="lineNum">    3292 </span>            :    *  @param  __b  Another thing of arbitrary type.
<span class="lineNum">    3293 </span>            :    *  @return A pair(__b, __a) if __b is smaller than __a, pair(__a,
<span class="lineNum">    3294 </span>            :    *  __b) otherwise.
<span class="lineNum">    3295 </span>            :   */
<span class="lineNum">    3296 </span>            :   template&lt;typename _Tp&gt;
<span class="lineNum">    3297 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3298 </span>            :     inline pair&lt;const _Tp&amp;, const _Tp&amp;&gt;
<span class="lineNum">    3299 </span>            :     minmax(const _Tp&amp; __a, const _Tp&amp; __b)
<span class="lineNum">    3300 </span>            :     {
<span class="lineNum">    3301 </span>            :       // concept requirements
<span class="lineNum">    3302 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;_Tp&gt;)
<span class="lineNum">    3303 </span>            : 
<span class="lineNum">    3304 </span>            :       return __b &lt; __a ? pair&lt;const _Tp&amp;, const _Tp&amp;&gt;(__b, __a)
<span class="lineNum">    3305 </span>            :                        : pair&lt;const _Tp&amp;, const _Tp&amp;&gt;(__a, __b);
<span class="lineNum">    3306 </span>            :     }
<span class="lineNum">    3307 </span>            : 
<span class="lineNum">    3308 </span>            :   /**
<span class="lineNum">    3309 </span>            :    *  @brief  Determines min and max at once as an ordered pair.
<span class="lineNum">    3310 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3311 </span>            :    *  @param  __a  A thing of arbitrary type.
<span class="lineNum">    3312 </span>            :    *  @param  __b  Another thing of arbitrary type.
<span class="lineNum">    3313 </span>            :    *  @param  __comp  A @link comparison_functors comparison functor @endlink.
<span class="lineNum">    3314 </span>            :    *  @return A pair(__b, __a) if __b is smaller than __a, pair(__a,
<span class="lineNum">    3315 </span>            :    *  __b) otherwise.
<span class="lineNum">    3316 </span>            :   */
<span class="lineNum">    3317 </span>            :   template&lt;typename _Tp, typename _Compare&gt;
<span class="lineNum">    3318 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3319 </span>            :     inline pair&lt;const _Tp&amp;, const _Tp&amp;&gt;
<span class="lineNum">    3320 </span>            :     minmax(const _Tp&amp; __a, const _Tp&amp; __b, _Compare __comp)
<span class="lineNum">    3321 </span>            :     {
<span class="lineNum">    3322 </span>            :       return __comp(__b, __a) ? pair&lt;const _Tp&amp;, const _Tp&amp;&gt;(__b, __a)
<span class="lineNum">    3323 </span>            :                               : pair&lt;const _Tp&amp;, const _Tp&amp;&gt;(__a, __b);
<span class="lineNum">    3324 </span>            :     }
<span class="lineNum">    3325 </span>            : 
<span class="lineNum">    3326 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    3327 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3328 </span>            :     pair&lt;_ForwardIterator, _ForwardIterator&gt;
<span class="lineNum">    3329 </span>            :     __minmax_element(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    3330 </span>            :                      _Compare __comp)
<span class="lineNum">    3331 </span>            :     {
<span class="lineNum">    3332 </span>            :       _ForwardIterator __next = __first;
<span class="lineNum">    3333 </span>            :       if (__first == __last
<span class="lineNum">    3334 </span>            :           || ++__next == __last)
<span class="lineNum">    3335 </span>            :         return std::make_pair(__first, __first);
<span class="lineNum">    3336 </span>            : 
<span class="lineNum">    3337 </span>            :       _ForwardIterator __min{}, __max{};
<span class="lineNum">    3338 </span>            :       if (__comp(__next, __first))
<span class="lineNum">    3339 </span>            :         {
<span class="lineNum">    3340 </span>            :           __min = __next;
<span class="lineNum">    3341 </span>            :           __max = __first;
<span class="lineNum">    3342 </span>            :         }
<span class="lineNum">    3343 </span>            :       else
<span class="lineNum">    3344 </span>            :         {
<span class="lineNum">    3345 </span>            :           __min = __first;
<span class="lineNum">    3346 </span>            :           __max = __next;
<span class="lineNum">    3347 </span>            :         }
<span class="lineNum">    3348 </span>            : 
<span class="lineNum">    3349 </span>            :       __first = __next;
<span class="lineNum">    3350 </span>            :       ++__first;
<span class="lineNum">    3351 </span>            : 
<span class="lineNum">    3352 </span>            :       while (__first != __last)
<span class="lineNum">    3353 </span>            :         {
<span class="lineNum">    3354 </span>            :           __next = __first;
<span class="lineNum">    3355 </span>            :           if (++__next == __last)
<span class="lineNum">    3356 </span>            :             {
<span class="lineNum">    3357 </span>            :               if (__comp(__first, __min))
<span class="lineNum">    3358 </span>            :                 __min = __first;
<span class="lineNum">    3359 </span>            :               else if (!__comp(__first, __max))
<span class="lineNum">    3360 </span>            :                 __max = __first;
<span class="lineNum">    3361 </span>            :               break;
<span class="lineNum">    3362 </span>            :             }
<span class="lineNum">    3363 </span>            : 
<span class="lineNum">    3364 </span>            :           if (__comp(__next, __first))
<span class="lineNum">    3365 </span>            :             {
<span class="lineNum">    3366 </span>            :               if (__comp(__next, __min))
<span class="lineNum">    3367 </span>            :                 __min = __next;
<span class="lineNum">    3368 </span>            :               if (!__comp(__first, __max))
<span class="lineNum">    3369 </span>            :                 __max = __first;
<span class="lineNum">    3370 </span>            :             }
<span class="lineNum">    3371 </span>            :           else
<span class="lineNum">    3372 </span>            :             {
<span class="lineNum">    3373 </span>            :               if (__comp(__first, __min))
<span class="lineNum">    3374 </span>            :                 __min = __first;
<span class="lineNum">    3375 </span>            :               if (!__comp(__next, __max))
<span class="lineNum">    3376 </span>            :                 __max = __next;
<span class="lineNum">    3377 </span>            :             }
<span class="lineNum">    3378 </span>            : 
<span class="lineNum">    3379 </span>            :           __first = __next;
<span class="lineNum">    3380 </span>            :           ++__first;
<span class="lineNum">    3381 </span>            :         }
<span class="lineNum">    3382 </span>            : 
<span class="lineNum">    3383 </span>            :       return std::make_pair(__min, __max);
<span class="lineNum">    3384 </span>            :     }
<span class="lineNum">    3385 </span>            : 
<span class="lineNum">    3386 </span>            :   /**
<span class="lineNum">    3387 </span>            :    *  @brief  Return a pair of iterators pointing to the minimum and maximum
<span class="lineNum">    3388 </span>            :    *          elements in a range.
<span class="lineNum">    3389 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3390 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    3391 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    3392 </span>            :    *  @return  make_pair(m, M), where m is the first iterator i in 
<span class="lineNum">    3393 </span>            :    *           [__first, __last) such that no other element in the range is
<span class="lineNum">    3394 </span>            :    *           smaller, and where M is the last iterator i in [__first, __last)
<span class="lineNum">    3395 </span>            :    *           such that no other element in the range is larger.
<span class="lineNum">    3396 </span>            :   */
<span class="lineNum">    3397 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">    3398 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3399 </span>            :     inline pair&lt;_ForwardIterator, _ForwardIterator&gt;
<span class="lineNum">    3400 </span>            :     minmax_element(_ForwardIterator __first, _ForwardIterator __last)
<span class="lineNum">    3401 </span>            :     {
<span class="lineNum">    3402 </span>            :       // concept requirements
<span class="lineNum">    3403 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    3404 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    3405 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    3406 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3407 </span>            : 
<span class="lineNum">    3408 </span>            :       return std::__minmax_element(__first, __last,
<span class="lineNum">    3409 </span>            :                                    __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    3410 </span>            :     }
<span class="lineNum">    3411 </span>            : 
<span class="lineNum">    3412 </span>            :   /**
<span class="lineNum">    3413 </span>            :    *  @brief  Return a pair of iterators pointing to the minimum and maximum
<span class="lineNum">    3414 </span>            :    *          elements in a range.
<span class="lineNum">    3415 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    3416 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    3417 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    3418 </span>            :    *  @param  __comp   Comparison functor.
<span class="lineNum">    3419 </span>            :    *  @return  make_pair(m, M), where m is the first iterator i in 
<span class="lineNum">    3420 </span>            :    *           [__first, __last) such that no other element in the range is
<span class="lineNum">    3421 </span>            :    *           smaller, and where M is the last iterator i in [__first, __last)
<span class="lineNum">    3422 </span>            :    *           such that no other element in the range is larger.
<span class="lineNum">    3423 </span>            :   */
<span class="lineNum">    3424 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    3425 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3426 </span>            :     inline pair&lt;_ForwardIterator, _ForwardIterator&gt;
<span class="lineNum">    3427 </span>            :     minmax_element(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    3428 </span>            :                    _Compare __comp)
<span class="lineNum">    3429 </span>            :     {
<span class="lineNum">    3430 </span>            :       // concept requirements
<span class="lineNum">    3431 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    3432 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    3433 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type,
<span class="lineNum">    3434 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    3435 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3436 </span>            : 
<span class="lineNum">    3437 </span>            :       return std::__minmax_element(__first, __last,
<span class="lineNum">    3438 </span>            :                                    __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    3439 </span>            :     }
<span class="lineNum">    3440 </span>            : 
<span class="lineNum">    3441 </span>            :   // N2722 + DR 915.
<span class="lineNum">    3442 </span>            :   template&lt;typename _Tp&gt;
<span class="lineNum">    3443 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3444 </span>            :     inline _Tp
<span class="lineNum">    3445 </span>            :     min(initializer_list&lt;_Tp&gt; __l)
<span class="lineNum">    3446 </span>            :     { return *std::min_element(__l.begin(), __l.end()); }
<span class="lineNum">    3447 </span>            : 
<span class="lineNum">    3448 </span>            :   template&lt;typename _Tp, typename _Compare&gt;
<span class="lineNum">    3449 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3450 </span>            :     inline _Tp
<span class="lineNum">    3451 </span>            :     min(initializer_list&lt;_Tp&gt; __l, _Compare __comp)
<span class="lineNum">    3452 </span>            :     { return *std::min_element(__l.begin(), __l.end(), __comp); }
<span class="lineNum">    3453 </span>            : 
<span class="lineNum">    3454 </span>            :   template&lt;typename _Tp&gt;
<span class="lineNum">    3455 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3456 </span>            :     inline _Tp
<span class="lineNum">    3457 </span>            :     max(initializer_list&lt;_Tp&gt; __l)
<span class="lineNum">    3458 </span>            :     { return *std::max_element(__l.begin(), __l.end()); }
<span class="lineNum">    3459 </span>            : 
<span class="lineNum">    3460 </span>            :   template&lt;typename _Tp, typename _Compare&gt;
<span class="lineNum">    3461 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3462 </span>            :     inline _Tp
<span class="lineNum">    3463 </span>            :     max(initializer_list&lt;_Tp&gt; __l, _Compare __comp)
<span class="lineNum">    3464 </span>            :     { return *std::max_element(__l.begin(), __l.end(), __comp); }
<span class="lineNum">    3465 </span>            : 
<span class="lineNum">    3466 </span>            :   template&lt;typename _Tp&gt;
<span class="lineNum">    3467 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3468 </span>            :     inline pair&lt;_Tp, _Tp&gt;
<span class="lineNum">    3469 </span>            :     minmax(initializer_list&lt;_Tp&gt; __l)
<span class="lineNum">    3470 </span>            :     {
<span class="lineNum">    3471 </span>            :       pair&lt;const _Tp*, const _Tp*&gt; __p =
<span class="lineNum">    3472 </span>            :         std::minmax_element(__l.begin(), __l.end());
<span class="lineNum">    3473 </span>            :       return std::make_pair(*__p.first, *__p.second);
<span class="lineNum">    3474 </span>            :     }
<span class="lineNum">    3475 </span>            : 
<span class="lineNum">    3476 </span>            :   template&lt;typename _Tp, typename _Compare&gt;
<span class="lineNum">    3477 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    3478 </span>            :     inline pair&lt;_Tp, _Tp&gt;
<span class="lineNum">    3479 </span>            :     minmax(initializer_list&lt;_Tp&gt; __l, _Compare __comp)
<span class="lineNum">    3480 </span>            :     {
<span class="lineNum">    3481 </span>            :       pair&lt;const _Tp*, const _Tp*&gt; __p =
<span class="lineNum">    3482 </span>            :         std::minmax_element(__l.begin(), __l.end(), __comp);
<span class="lineNum">    3483 </span>            :       return std::make_pair(*__p.first, *__p.second);
<span class="lineNum">    3484 </span>            :     }
<span class="lineNum">    3485 </span>            : 
<span class="lineNum">    3486 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2,
<span class="lineNum">    3487 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    3488 </span>            :     bool
<span class="lineNum">    3489 </span>            :     __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">    3490 </span>            :                      _ForwardIterator2 __first2, _BinaryPredicate __pred)
<span class="lineNum">    3491 </span>            :     {
<span class="lineNum">    3492 </span>            :       // Efficiently compare identical prefixes:  O(N) if sequences
<span class="lineNum">    3493 </span>            :       // have the same elements in the same order.
<span class="lineNum">    3494 </span>            :       for (; __first1 != __last1; ++__first1, ++__first2)
<span class="lineNum">    3495 </span>            :         if (!__pred(__first1, __first2))
<span class="lineNum">    3496 </span>            :           break;
<span class="lineNum">    3497 </span>            : 
<span class="lineNum">    3498 </span>            :       if (__first1 == __last1)
<span class="lineNum">    3499 </span>            :         return true;
<span class="lineNum">    3500 </span>            : 
<span class="lineNum">    3501 </span>            :       // Establish __last2 assuming equal ranges by iterating over the
<span class="lineNum">    3502 </span>            :       // rest of the list.
<span class="lineNum">    3503 </span>            :       _ForwardIterator2 __last2 = __first2;
<span class="lineNum">    3504 </span>            :       std::advance(__last2, std::distance(__first1, __last1));
<span class="lineNum">    3505 </span>            :       for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
<span class="lineNum">    3506 </span>            :         {
<span class="lineNum">    3507 </span>            :           if (__scan != std::__find_if(__first1, __scan,
<span class="lineNum">    3508 </span>            :                           __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)))
<span class="lineNum">    3509 </span>            :             continue; // We've seen this one before.
<span class="lineNum">    3510 </span>            :           
<span class="lineNum">    3511 </span>            :           auto __matches
<span class="lineNum">    3512 </span>            :             = std::__count_if(__first2, __last2,
<span class="lineNum">    3513 </span>            :                         __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan));
<span class="lineNum">    3514 </span>            :           if (0 == __matches ||
<span class="lineNum">    3515 </span>            :               std::__count_if(__scan, __last1,
<span class="lineNum">    3516 </span>            :                         __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))
<span class="lineNum">    3517 </span>            :               != __matches)
<span class="lineNum">    3518 </span>            :             return false;
<span class="lineNum">    3519 </span>            :         }
<span class="lineNum">    3520 </span>            :       return true;
<span class="lineNum">    3521 </span>            :     }
<span class="lineNum">    3522 </span>            : 
<span class="lineNum">    3523 </span>            :   /**
<span class="lineNum">    3524 </span>            :    *  @brief  Checks whether a permutation of the second sequence is equal
<span class="lineNum">    3525 </span>            :    *          to the first sequence.
<span class="lineNum">    3526 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3527 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    3528 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    3529 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    3530 </span>            :    *  @return true if there exists a permutation of the elements in the range
<span class="lineNum">    3531 </span>            :    *          [__first2, __first2 + (__last1 - __first1)), beginning with 
<span class="lineNum">    3532 </span>            :    *          ForwardIterator2 begin, such that equal(__first1, __last1, begin)
<span class="lineNum">    3533 </span>            :    *          returns true; otherwise, returns false.
<span class="lineNum">    3534 </span>            :   */
<span class="lineNum">    3535 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2&gt;
<span class="lineNum">    3536 </span>            :     inline bool
<span class="lineNum">    3537 </span>            :     is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">    3538 </span>            :                    _ForwardIterator2 __first2)
<span class="lineNum">    3539 </span>            :     {
<span class="lineNum">    3540 </span>            :       // concept requirements
<span class="lineNum">    3541 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator1&gt;)
<span class="lineNum">    3542 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator2&gt;)
<span class="lineNum">    3543 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">    3544 </span>            :                 typename iterator_traits&lt;_ForwardIterator1&gt;::value_type,
<span class="lineNum">    3545 </span>            :                 typename iterator_traits&lt;_ForwardIterator2&gt;::value_type&gt;)
<span class="lineNum">    3546 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    3547 </span>            : 
<span class="lineNum">    3548 </span>            :       return std::__is_permutation(__first1, __last1, __first2,
<span class="lineNum">    3549 </span>            :                                    __gnu_cxx::__ops::__iter_equal_to_iter());
<span class="lineNum">    3550 </span>            :     }
<span class="lineNum">    3551 </span>            : 
<span class="lineNum">    3552 </span>            :   /**
<span class="lineNum">    3553 </span>            :    *  @brief  Checks whether a permutation of the second sequence is equal
<span class="lineNum">    3554 </span>            :    *          to the first sequence.
<span class="lineNum">    3555 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3556 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    3557 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    3558 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    3559 </span>            :    *  @param  __pred    A binary predicate.
<span class="lineNum">    3560 </span>            :    *  @return true if there exists a permutation of the elements in
<span class="lineNum">    3561 </span>            :    *          the range [__first2, __first2 + (__last1 - __first1)),
<span class="lineNum">    3562 </span>            :    *          beginning with ForwardIterator2 begin, such that
<span class="lineNum">    3563 </span>            :    *          equal(__first1, __last1, __begin, __pred) returns true;
<span class="lineNum">    3564 </span>            :    *          otherwise, returns false.
<span class="lineNum">    3565 </span>            :   */
<span class="lineNum">    3566 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2,
<span class="lineNum">    3567 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    3568 </span>            :     inline bool
<span class="lineNum">    3569 </span>            :     is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">    3570 </span>            :                    _ForwardIterator2 __first2, _BinaryPredicate __pred)
<span class="lineNum">    3571 </span>            :     {
<span class="lineNum">    3572 </span>            :       // concept requirements
<span class="lineNum">    3573 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator1&gt;)
<span class="lineNum">    3574 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator2&gt;)
<span class="lineNum">    3575 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    3576 </span>            :             typename iterator_traits&lt;_ForwardIterator1&gt;::value_type,
<span class="lineNum">    3577 </span>            :             typename iterator_traits&lt;_ForwardIterator2&gt;::value_type&gt;)
<span class="lineNum">    3578 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    3579 </span>            : 
<span class="lineNum">    3580 </span>            :       return std::__is_permutation(__first1, __last1, __first2,
<span class="lineNum">    3581 </span>            :                                    __gnu_cxx::__ops::__iter_comp_iter(__pred));
<span class="lineNum">    3582 </span>            :     }
<span class="lineNum">    3583 </span>            : 
<span class="lineNum">    3584 </span>            : #if __cplusplus &gt; 201103L
<span class="lineNum">    3585 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2,
<span class="lineNum">    3586 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    3587 </span>            :     bool
<span class="lineNum">    3588 </span>            :     __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">    3589 </span>            :                      _ForwardIterator2 __first2, _ForwardIterator2 __last2,
<span class="lineNum">    3590 </span>            :                      _BinaryPredicate __pred)
<span class="lineNum">    3591 </span>            :     {
<span class="lineNum">    3592 </span>            :       using _Cat1
<span class="lineNum">    3593 </span>            :         = typename iterator_traits&lt;_ForwardIterator1&gt;::iterator_category;
<span class="lineNum">    3594 </span>            :       using _Cat2
<span class="lineNum">    3595 </span>            :         = typename iterator_traits&lt;_ForwardIterator2&gt;::iterator_category;
<span class="lineNum">    3596 </span>            :       using _It1_is_RA = is_same&lt;_Cat1, random_access_iterator_tag&gt;;
<span class="lineNum">    3597 </span>            :       using _It2_is_RA = is_same&lt;_Cat2, random_access_iterator_tag&gt;;
<span class="lineNum">    3598 </span>            :       constexpr bool __ra_iters = _It1_is_RA() &amp;&amp; _It2_is_RA();
<span class="lineNum">    3599 </span>            :       if (__ra_iters)
<span class="lineNum">    3600 </span>            :         {
<span class="lineNum">    3601 </span>            :           auto __d1 = std::distance(__first1, __last1);
<span class="lineNum">    3602 </span>            :           auto __d2 = std::distance(__first2, __last2);
<span class="lineNum">    3603 </span>            :           if (__d1 != __d2)
<span class="lineNum">    3604 </span>            :             return false;
<span class="lineNum">    3605 </span>            :         }
<span class="lineNum">    3606 </span>            : 
<span class="lineNum">    3607 </span>            :       // Efficiently compare identical prefixes:  O(N) if sequences
<span class="lineNum">    3608 </span>            :       // have the same elements in the same order.
<span class="lineNum">    3609 </span>            :       for (; __first1 != __last1 &amp;&amp; __first2 != __last2;
<span class="lineNum">    3610 </span>            :           ++__first1, ++__first2)
<span class="lineNum">    3611 </span>            :         if (!__pred(__first1, __first2))
<span class="lineNum">    3612 </span>            :           break;
<span class="lineNum">    3613 </span>            : 
<span class="lineNum">    3614 </span>            :       if (__ra_iters)
<span class="lineNum">    3615 </span>            :         {
<span class="lineNum">    3616 </span>            :           if (__first1 == __last1)
<span class="lineNum">    3617 </span>            :             return true;
<span class="lineNum">    3618 </span>            :         }
<span class="lineNum">    3619 </span>            :       else
<span class="lineNum">    3620 </span>            :         {
<span class="lineNum">    3621 </span>            :           auto __d1 = std::distance(__first1, __last1);
<span class="lineNum">    3622 </span>            :           auto __d2 = std::distance(__first2, __last2);
<span class="lineNum">    3623 </span>            :           if (__d1 == 0 &amp;&amp; __d2 == 0)
<span class="lineNum">    3624 </span>            :             return true;
<span class="lineNum">    3625 </span>            :           if (__d1 != __d2)
<span class="lineNum">    3626 </span>            :             return false;
<span class="lineNum">    3627 </span>            :         }
<span class="lineNum">    3628 </span>            : 
<span class="lineNum">    3629 </span>            :       for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
<span class="lineNum">    3630 </span>            :         {
<span class="lineNum">    3631 </span>            :           if (__scan != std::__find_if(__first1, __scan,
<span class="lineNum">    3632 </span>            :                         __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)))
<span class="lineNum">    3633 </span>            :             continue; // We've seen this one before.
<span class="lineNum">    3634 </span>            : 
<span class="lineNum">    3635 </span>            :           auto __matches = std::__count_if(__first2, __last2,
<span class="lineNum">    3636 </span>            :                 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan));
<span class="lineNum">    3637 </span>            :           if (0 == __matches
<span class="lineNum">    3638 </span>            :               || std::__count_if(__scan, __last1,
<span class="lineNum">    3639 </span>            :                         __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))
<span class="lineNum">    3640 </span>            :               != __matches)
<span class="lineNum">    3641 </span>            :             return false;
<span class="lineNum">    3642 </span>            :         }
<span class="lineNum">    3643 </span>            :       return true;
<span class="lineNum">    3644 </span>            :     }
<span class="lineNum">    3645 </span>            : 
<span class="lineNum">    3646 </span>            :   /**
<span class="lineNum">    3647 </span>            :    *  @brief  Checks whether a permutaion of the second sequence is equal
<span class="lineNum">    3648 </span>            :    *          to the first sequence.
<span class="lineNum">    3649 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3650 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    3651 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    3652 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    3653 </span>            :    *  @param  __last2   End of first range.
<span class="lineNum">    3654 </span>            :    *  @return true if there exists a permutation of the elements in the range
<span class="lineNum">    3655 </span>            :    *          [__first2, __last2), beginning with ForwardIterator2 begin,
<span class="lineNum">    3656 </span>            :    *          such that equal(__first1, __last1, begin) returns true;
<span class="lineNum">    3657 </span>            :    *          otherwise, returns false.
<span class="lineNum">    3658 </span>            :   */
<span class="lineNum">    3659 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2&gt;
<span class="lineNum">    3660 </span>            :     inline bool
<span class="lineNum">    3661 </span>            :     is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">    3662 </span>            :                    _ForwardIterator2 __first2, _ForwardIterator2 __last2)
<span class="lineNum">    3663 </span>            :     {
<span class="lineNum">    3664 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    3665 </span>            :       __glibcxx_requires_valid_range(__first2, __last2);
<span class="lineNum">    3666 </span>            : 
<span class="lineNum">    3667 </span>            :       return
<span class="lineNum">    3668 </span>            :         std::__is_permutation(__first1, __last1, __first2, __last2,
<span class="lineNum">    3669 </span>            :                               __gnu_cxx::__ops::__iter_equal_to_iter());
<span class="lineNum">    3670 </span>            :     }
<span class="lineNum">    3671 </span>            : 
<span class="lineNum">    3672 </span>            :   /**
<span class="lineNum">    3673 </span>            :    *  @brief  Checks whether a permutation of the second sequence is equal
<span class="lineNum">    3674 </span>            :    *          to the first sequence.
<span class="lineNum">    3675 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3676 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    3677 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    3678 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    3679 </span>            :    *  @param  __last2   End of first range.
<span class="lineNum">    3680 </span>            :    *  @param  __pred    A binary predicate.
<span class="lineNum">    3681 </span>            :    *  @return true if there exists a permutation of the elements in the range
<span class="lineNum">    3682 </span>            :    *          [__first2, __last2), beginning with ForwardIterator2 begin,
<span class="lineNum">    3683 </span>            :    *          such that equal(__first1, __last1, __begin, __pred) returns true;
<span class="lineNum">    3684 </span>            :    *          otherwise, returns false.
<span class="lineNum">    3685 </span>            :   */
<span class="lineNum">    3686 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2,
<span class="lineNum">    3687 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    3688 </span>            :     inline bool
<span class="lineNum">    3689 </span>            :     is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">    3690 </span>            :                    _ForwardIterator2 __first2, _ForwardIterator2 __last2,
<span class="lineNum">    3691 </span>            :                    _BinaryPredicate __pred)
<span class="lineNum">    3692 </span>            :     {
<span class="lineNum">    3693 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    3694 </span>            :       __glibcxx_requires_valid_range(__first2, __last2);
<span class="lineNum">    3695 </span>            : 
<span class="lineNum">    3696 </span>            :       return std::__is_permutation(__first1, __last1, __first2, __last2,
<span class="lineNum">    3697 </span>            :                                    __gnu_cxx::__ops::__iter_comp_iter(__pred));
<span class="lineNum">    3698 </span>            :     }
<span class="lineNum">    3699 </span>            : #endif
<span class="lineNum">    3700 </span>            : 
<span class="lineNum">    3701 </span>            : #ifdef _GLIBCXX_USE_C99_STDINT_TR1
<span class="lineNum">    3702 </span>            :   /**
<span class="lineNum">    3703 </span>            :    *  @brief Shuffle the elements of a sequence using a uniform random
<span class="lineNum">    3704 </span>            :    *         number generator.
<span class="lineNum">    3705 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    3706 </span>            :    *  @param  __first   A forward iterator.
<span class="lineNum">    3707 </span>            :    *  @param  __last    A forward iterator.
<span class="lineNum">    3708 </span>            :    *  @param  __g       A UniformRandomNumberGenerator (26.5.1.3).
<span class="lineNum">    3709 </span>            :    *  @return  Nothing.
<span class="lineNum">    3710 </span>            :    *
<span class="lineNum">    3711 </span>            :    *  Reorders the elements in the range @p [__first,__last) using @p __g to
<span class="lineNum">    3712 </span>            :    *  provide random numbers.
<span class="lineNum">    3713 </span>            :   */
<span class="lineNum">    3714 </span>            :   template&lt;typename _RandomAccessIterator,
<span class="lineNum">    3715 </span>            :            typename _UniformRandomNumberGenerator&gt;
<span class="lineNum">    3716 </span>            :     void
<span class="lineNum">    3717 </span>            :     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
<span class="lineNum">    3718 </span>            :             _UniformRandomNumberGenerator&amp;&amp; __g)
<span class="lineNum">    3719 </span>            :     {
<span class="lineNum">    3720 </span>            :       // concept requirements
<span class="lineNum">    3721 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    3722 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    3723 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3724 </span>            : 
<span class="lineNum">    3725 </span>            :       if (__first == __last)
<span class="lineNum">    3726 </span>            :         return;
<span class="lineNum">    3727 </span>            : 
<span class="lineNum">    3728 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::difference_type
<span class="lineNum">    3729 </span>            :         _DistanceType;
<span class="lineNum">    3730 </span>            : 
<span class="lineNum">    3731 </span>            :       typedef typename std::make_unsigned&lt;_DistanceType&gt;::type __ud_type;
<span class="lineNum">    3732 </span>            :       typedef typename std::uniform_int_distribution&lt;__ud_type&gt; __distr_type;
<span class="lineNum">    3733 </span>            :       typedef typename __distr_type::param_type __p_type;
<span class="lineNum">    3734 </span>            :       __distr_type __d;
<span class="lineNum">    3735 </span>            : 
<span class="lineNum">    3736 </span>            :       for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
<span class="lineNum">    3737 </span>            :         std::iter_swap(__i, __first + __d(__g, __p_type(0, __i - __first)));
<span class="lineNum">    3738 </span>            :     }
<span class="lineNum">    3739 </span>            : #endif
<span class="lineNum">    3740 </span>            : 
<span class="lineNum">    3741 </span>            : #endif // C++11
<span class="lineNum">    3742 </span>            : 
<span class="lineNum">    3743 </span>            : _GLIBCXX_END_NAMESPACE_VERSION
<span class="lineNum">    3744 </span>            : 
<span class="lineNum">    3745 </span>            : _GLIBCXX_BEGIN_NAMESPACE_ALGO
<span class="lineNum">    3746 </span>            : 
<span class="lineNum">    3747 </span>            :   /**
<span class="lineNum">    3748 </span>            :    *  @brief Apply a function to every element of a sequence.
<span class="lineNum">    3749 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3750 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">    3751 </span>            :    *  @param  __last   An input iterator.
<span class="lineNum">    3752 </span>            :    *  @param  __f      A unary function object.
<span class="lineNum">    3753 </span>            :    *  @return   @p __f (std::move(@p __f) in C++0x).
<span class="lineNum">    3754 </span>            :    *
<span class="lineNum">    3755 </span>            :    *  Applies the function object @p __f to each element in the range
<span class="lineNum">    3756 </span>            :    *  @p [first,last).  @p __f must not modify the order of the sequence.
<span class="lineNum">    3757 </span>            :    *  If @p __f has a return value it is ignored.
<span class="lineNum">    3758 </span>            :   */
<span class="lineNum">    3759 </span>            :   template&lt;typename _InputIterator, typename _Function&gt;
<span class="lineNum">    3760 </span>            :     _Function
<span class="lineNum">    3761 </span>            :     for_each(_InputIterator __first, _InputIterator __last, _Function __f)
<span class="lineNum">    3762 </span>            :     {
<span class="lineNum">    3763 </span>            :       // concept requirements
<span class="lineNum">    3764 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3765 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3766 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">    3767 </span>            :         __f(*__first);
<span class="lineNum">    3768 </span>            :       return _GLIBCXX_MOVE(__f);
<span class="lineNum">    3769 </span>            :     }
<span class="lineNum">    3770 </span>            : 
<span class="lineNum">    3771 </span>            :   /**
<span class="lineNum">    3772 </span>            :    *  @brief Find the first occurrence of a value in a sequence.
<span class="lineNum">    3773 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3774 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">    3775 </span>            :    *  @param  __last   An input iterator.
<span class="lineNum">    3776 </span>            :    *  @param  __val    The value to find.
<span class="lineNum">    3777 </span>            :    *  @return   The first iterator @c i in the range @p [__first,__last)
<span class="lineNum">    3778 </span>            :    *  such that @c *i == @p __val, or @p __last if no such iterator exists.
<span class="lineNum">    3779 </span>            :   */
<span class="lineNum">    3780 </span>            :   template&lt;typename _InputIterator, typename _Tp&gt;
<span class="lineNum">    3781 </span>            :     inline _InputIterator
<span class="lineNum">    3782 </span>            :     find(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    3783 </span>            :          const _Tp&amp; __val)
<span class="lineNum">    3784 </span>            :     {
<span class="lineNum">    3785 </span>            :       // concept requirements
<span class="lineNum">    3786 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3787 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">    3788 </span>            :                 typename iterator_traits&lt;_InputIterator&gt;::value_type, _Tp&gt;)
<span class="lineNum">    3789 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3790 </span>            :       return std::__find_if(__first, __last,
<span class="lineNum">    3791 </span>            :                             __gnu_cxx::__ops::__iter_equals_val(__val));
<span class="lineNum">    3792 </span>            :     }
<span class="lineNum">    3793 </span>            : 
<span class="lineNum">    3794 </span>            :   /**
<span class="lineNum">    3795 </span>            :    *  @brief Find the first element in a sequence for which a
<span class="lineNum">    3796 </span>            :    *         predicate is true.
<span class="lineNum">    3797 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3798 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">    3799 </span>            :    *  @param  __last   An input iterator.
<span class="lineNum">    3800 </span>            :    *  @param  __pred   A predicate.
<span class="lineNum">    3801 </span>            :    *  @return   The first iterator @c i in the range @p [__first,__last)
<span class="lineNum">    3802 </span>            :    *  such that @p __pred(*i) is true, or @p __last if no such iterator exists.
<span class="lineNum">    3803 </span>            :   */
<a name="3804"><span class="lineNum">    3804 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;</a>
<span class="lineNum">    3805 </span>            :     inline _InputIterator
<span class="lineNum">    3806 </span><span class="lineCov">          1 :     find_if(_InputIterator __first, _InputIterator __last,</span>
<span class="lineNum">    3807 </span>            :             _Predicate __pred)
<span class="lineNum">    3808 </span>            :     {
<span class="lineNum">    3809 </span>            :       // concept requirements
<span class="lineNum">    3810 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3811 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">    3812 </span>            :               typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    3813 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3814 </span>            : 
<span class="lineNum">    3815 </span><span class="lineCov">          2 :       return std::__find_if(__first, __last,</span>
<span class="lineNum">    3816 </span><span class="lineCov">          2 :                             __gnu_cxx::__ops::__pred_iter(__pred));</span>
<span class="lineNum">    3817 </span>            :     }
<span class="lineNum">    3818 </span>            : 
<span class="lineNum">    3819 </span>            :   /**
<span class="lineNum">    3820 </span>            :    *  @brief  Find element from a set in a sequence.
<span class="lineNum">    3821 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3822 </span>            :    *  @param  __first1  Start of range to search.
<span class="lineNum">    3823 </span>            :    *  @param  __last1   End of range to search.
<span class="lineNum">    3824 </span>            :    *  @param  __first2  Start of match candidates.
<span class="lineNum">    3825 </span>            :    *  @param  __last2   End of match candidates.
<span class="lineNum">    3826 </span>            :    *  @return   The first iterator @c i in the range
<span class="lineNum">    3827 </span>            :    *  @p [__first1,__last1) such that @c *i == @p *(i2) such that i2 is an
<span class="lineNum">    3828 </span>            :    *  iterator in [__first2,__last2), or @p __last1 if no such iterator exists.
<span class="lineNum">    3829 </span>            :    *
<span class="lineNum">    3830 </span>            :    *  Searches the range @p [__first1,__last1) for an element that is
<span class="lineNum">    3831 </span>            :    *  equal to some element in the range [__first2,__last2).  If
<span class="lineNum">    3832 </span>            :    *  found, returns an iterator in the range [__first1,__last1),
<span class="lineNum">    3833 </span>            :    *  otherwise returns @p __last1.
<span class="lineNum">    3834 </span>            :   */
<span class="lineNum">    3835 </span>            :   template&lt;typename _InputIterator, typename _ForwardIterator&gt;
<span class="lineNum">    3836 </span>            :     _InputIterator
<span class="lineNum">    3837 </span>            :     find_first_of(_InputIterator __first1, _InputIterator __last1,
<span class="lineNum">    3838 </span>            :                   _ForwardIterator __first2, _ForwardIterator __last2)
<span class="lineNum">    3839 </span>            :     {
<span class="lineNum">    3840 </span>            :       // concept requirements
<span class="lineNum">    3841 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3842 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    3843 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">    3844 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type,
<span class="lineNum">    3845 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    3846 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    3847 </span>            :       __glibcxx_requires_valid_range(__first2, __last2);
<span class="lineNum">    3848 </span>            : 
<span class="lineNum">    3849 </span>            :       for (; __first1 != __last1; ++__first1)
<span class="lineNum">    3850 </span>            :         for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
<span class="lineNum">    3851 </span>            :           if (*__first1 == *__iter)
<span class="lineNum">    3852 </span>            :             return __first1;
<span class="lineNum">    3853 </span>            :       return __last1;
<span class="lineNum">    3854 </span>            :     }
<span class="lineNum">    3855 </span>            : 
<span class="lineNum">    3856 </span>            :   /**
<span class="lineNum">    3857 </span>            :    *  @brief  Find element from a set in a sequence using a predicate.
<span class="lineNum">    3858 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3859 </span>            :    *  @param  __first1  Start of range to search.
<span class="lineNum">    3860 </span>            :    *  @param  __last1   End of range to search.
<span class="lineNum">    3861 </span>            :    *  @param  __first2  Start of match candidates.
<span class="lineNum">    3862 </span>            :    *  @param  __last2   End of match candidates.
<span class="lineNum">    3863 </span>            :    *  @param  __comp    Predicate to use.
<span class="lineNum">    3864 </span>            :    *  @return   The first iterator @c i in the range
<span class="lineNum">    3865 </span>            :    *  @p [__first1,__last1) such that @c comp(*i, @p *(i2)) is true
<span class="lineNum">    3866 </span>            :    *  and i2 is an iterator in [__first2,__last2), or @p __last1 if no
<span class="lineNum">    3867 </span>            :    *  such iterator exists.
<span class="lineNum">    3868 </span>            :    *
<span class="lineNum">    3869 </span>            : 
<span class="lineNum">    3870 </span>            :    *  Searches the range @p [__first1,__last1) for an element that is
<span class="lineNum">    3871 </span>            :    *  equal to some element in the range [__first2,__last2).  If
<span class="lineNum">    3872 </span>            :    *  found, returns an iterator in the range [__first1,__last1),
<span class="lineNum">    3873 </span>            :    *  otherwise returns @p __last1.
<span class="lineNum">    3874 </span>            :   */
<span class="lineNum">    3875 </span>            :   template&lt;typename _InputIterator, typename _ForwardIterator,
<span class="lineNum">    3876 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    3877 </span>            :     _InputIterator
<span class="lineNum">    3878 </span>            :     find_first_of(_InputIterator __first1, _InputIterator __last1,
<span class="lineNum">    3879 </span>            :                   _ForwardIterator __first2, _ForwardIterator __last2,
<span class="lineNum">    3880 </span>            :                   _BinaryPredicate __comp)
<span class="lineNum">    3881 </span>            :     {
<span class="lineNum">    3882 </span>            :       // concept requirements
<span class="lineNum">    3883 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3884 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    3885 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    3886 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type,
<span class="lineNum">    3887 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    3888 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    3889 </span>            :       __glibcxx_requires_valid_range(__first2, __last2);
<span class="lineNum">    3890 </span>            : 
<span class="lineNum">    3891 </span>            :       for (; __first1 != __last1; ++__first1)
<span class="lineNum">    3892 </span>            :         for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
<span class="lineNum">    3893 </span>            :           if (__comp(*__first1, *__iter))
<span class="lineNum">    3894 </span>            :             return __first1;
<span class="lineNum">    3895 </span>            :       return __last1;
<span class="lineNum">    3896 </span>            :     }
<span class="lineNum">    3897 </span>            : 
<span class="lineNum">    3898 </span>            :   /**
<span class="lineNum">    3899 </span>            :    *  @brief Find two adjacent values in a sequence that are equal.
<span class="lineNum">    3900 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3901 </span>            :    *  @param  __first  A forward iterator.
<span class="lineNum">    3902 </span>            :    *  @param  __last   A forward iterator.
<span class="lineNum">    3903 </span>            :    *  @return   The first iterator @c i such that @c i and @c i+1 are both
<span class="lineNum">    3904 </span>            :    *  valid iterators in @p [__first,__last) and such that @c *i == @c *(i+1),
<span class="lineNum">    3905 </span>            :    *  or @p __last if no such iterator exists.
<span class="lineNum">    3906 </span>            :   */
<span class="lineNum">    3907 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">    3908 </span>            :     inline _ForwardIterator
<span class="lineNum">    3909 </span>            :     adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
<span class="lineNum">    3910 </span>            :     {
<span class="lineNum">    3911 </span>            :       // concept requirements
<span class="lineNum">    3912 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    3913 </span>            :       __glibcxx_function_requires(_EqualityComparableConcept&lt;
<span class="lineNum">    3914 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    3915 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3916 </span>            : 
<span class="lineNum">    3917 </span>            :       return std::__adjacent_find(__first, __last,
<span class="lineNum">    3918 </span>            :                                   __gnu_cxx::__ops::__iter_equal_to_iter());
<span class="lineNum">    3919 </span>            :     }
<span class="lineNum">    3920 </span>            : 
<span class="lineNum">    3921 </span>            :   /**
<span class="lineNum">    3922 </span>            :    *  @brief Find two adjacent values in a sequence using a predicate.
<span class="lineNum">    3923 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3924 </span>            :    *  @param  __first         A forward iterator.
<span class="lineNum">    3925 </span>            :    *  @param  __last          A forward iterator.
<span class="lineNum">    3926 </span>            :    *  @param  __binary_pred   A binary predicate.
<span class="lineNum">    3927 </span>            :    *  @return   The first iterator @c i such that @c i and @c i+1 are both
<span class="lineNum">    3928 </span>            :    *  valid iterators in @p [__first,__last) and such that
<span class="lineNum">    3929 </span>            :    *  @p __binary_pred(*i,*(i+1)) is true, or @p __last if no such iterator
<span class="lineNum">    3930 </span>            :    *  exists.
<span class="lineNum">    3931 </span>            :   */
<span class="lineNum">    3932 </span>            :   template&lt;typename _ForwardIterator, typename _BinaryPredicate&gt;
<span class="lineNum">    3933 </span>            :     inline _ForwardIterator
<span class="lineNum">    3934 </span>            :     adjacent_find(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    3935 </span>            :                   _BinaryPredicate __binary_pred)
<span class="lineNum">    3936 </span>            :     {
<span class="lineNum">    3937 </span>            :       // concept requirements
<span class="lineNum">    3938 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    3939 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    3940 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type,
<span class="lineNum">    3941 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    3942 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3943 </span>            : 
<span class="lineNum">    3944 </span>            :       return std::__adjacent_find(__first, __last,
<span class="lineNum">    3945 </span>            :                         __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
<span class="lineNum">    3946 </span>            :     }
<span class="lineNum">    3947 </span>            : 
<span class="lineNum">    3948 </span>            :   /**
<span class="lineNum">    3949 </span>            :    *  @brief Count the number of copies of a value in a sequence.
<span class="lineNum">    3950 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3951 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">    3952 </span>            :    *  @param  __last   An input iterator.
<span class="lineNum">    3953 </span>            :    *  @param  __value  The value to be counted.
<span class="lineNum">    3954 </span>            :    *  @return   The number of iterators @c i in the range @p [__first,__last)
<span class="lineNum">    3955 </span>            :    *  for which @c *i == @p __value
<span class="lineNum">    3956 </span>            :   */
<span class="lineNum">    3957 </span>            :   template&lt;typename _InputIterator, typename _Tp&gt;
<span class="lineNum">    3958 </span>            :     inline typename iterator_traits&lt;_InputIterator&gt;::difference_type
<span class="lineNum">    3959 </span>            :     count(_InputIterator __first, _InputIterator __last, const _Tp&amp; __value)
<span class="lineNum">    3960 </span>            :     {
<span class="lineNum">    3961 </span>            :       // concept requirements
<span class="lineNum">    3962 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3963 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">    3964 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type, _Tp&gt;)
<span class="lineNum">    3965 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3966 </span>            : 
<span class="lineNum">    3967 </span>            :       return std::__count_if(__first, __last,
<span class="lineNum">    3968 </span>            :                              __gnu_cxx::__ops::__iter_equals_val(__value));
<span class="lineNum">    3969 </span>            :     }
<span class="lineNum">    3970 </span>            : 
<span class="lineNum">    3971 </span>            :   /**
<span class="lineNum">    3972 </span>            :    *  @brief Count the elements of a sequence for which a predicate is true.
<span class="lineNum">    3973 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3974 </span>            :    *  @param  __first  An input iterator.
<span class="lineNum">    3975 </span>            :    *  @param  __last   An input iterator.
<span class="lineNum">    3976 </span>            :    *  @param  __pred   A predicate.
<span class="lineNum">    3977 </span>            :    *  @return   The number of iterators @c i in the range @p [__first,__last)
<span class="lineNum">    3978 </span>            :    *  for which @p __pred(*i) is true.
<span class="lineNum">    3979 </span>            :   */
<span class="lineNum">    3980 </span>            :   template&lt;typename _InputIterator, typename _Predicate&gt;
<span class="lineNum">    3981 </span>            :     inline typename iterator_traits&lt;_InputIterator&gt;::difference_type
<span class="lineNum">    3982 </span>            :     count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
<span class="lineNum">    3983 </span>            :     {
<span class="lineNum">    3984 </span>            :       // concept requirements
<span class="lineNum">    3985 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    3986 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">    3987 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    3988 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    3989 </span>            : 
<span class="lineNum">    3990 </span>            :       return std::__count_if(__first, __last,
<span class="lineNum">    3991 </span>            :                              __gnu_cxx::__ops::__pred_iter(__pred));
<span class="lineNum">    3992 </span>            :     }
<span class="lineNum">    3993 </span>            : 
<span class="lineNum">    3994 </span>            :   /**
<span class="lineNum">    3995 </span>            :    *  @brief Search a sequence for a matching sub-sequence.
<span class="lineNum">    3996 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    3997 </span>            :    *  @param  __first1  A forward iterator.
<span class="lineNum">    3998 </span>            :    *  @param  __last1   A forward iterator.
<span class="lineNum">    3999 </span>            :    *  @param  __first2  A forward iterator.
<span class="lineNum">    4000 </span>            :    *  @param  __last2   A forward iterator.
<span class="lineNum">    4001 </span>            :    *  @return The first iterator @c i in the range @p
<span class="lineNum">    4002 </span>            :    *  [__first1,__last1-(__last2-__first2)) such that @c *(i+N) == @p
<span class="lineNum">    4003 </span>            :    *  *(__first2+N) for each @c N in the range @p
<span class="lineNum">    4004 </span>            :    *  [0,__last2-__first2), or @p __last1 if no such iterator exists.
<span class="lineNum">    4005 </span>            :    *
<span class="lineNum">    4006 </span>            :    *  Searches the range @p [__first1,__last1) for a sub-sequence that
<span class="lineNum">    4007 </span>            :    *  compares equal value-by-value with the sequence given by @p
<span class="lineNum">    4008 </span>            :    *  [__first2,__last2) and returns an iterator to the first element
<span class="lineNum">    4009 </span>            :    *  of the sub-sequence, or @p __last1 if the sub-sequence is not
<span class="lineNum">    4010 </span>            :    *  found.
<span class="lineNum">    4011 </span>            :    *
<span class="lineNum">    4012 </span>            :    *  Because the sub-sequence must lie completely within the range @p
<span class="lineNum">    4013 </span>            :    *  [__first1,__last1) it must start at a position less than @p
<span class="lineNum">    4014 </span>            :    *  __last1-(__last2-__first2) where @p __last2-__first2 is the
<span class="lineNum">    4015 </span>            :    *  length of the sub-sequence.
<span class="lineNum">    4016 </span>            :    *
<span class="lineNum">    4017 </span>            :    *  This means that the returned iterator @c i will be in the range
<span class="lineNum">    4018 </span>            :    *  @p [__first1,__last1-(__last2-__first2))
<span class="lineNum">    4019 </span>            :   */
<span class="lineNum">    4020 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2&gt;
<span class="lineNum">    4021 </span>            :     inline _ForwardIterator1
<span class="lineNum">    4022 </span>            :     search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">    4023 </span>            :            _ForwardIterator2 __first2, _ForwardIterator2 __last2)
<span class="lineNum">    4024 </span>            :     {
<span class="lineNum">    4025 </span>            :       // concept requirements
<span class="lineNum">    4026 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator1&gt;)
<span class="lineNum">    4027 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator2&gt;)
<span class="lineNum">    4028 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">    4029 </span>            :             typename iterator_traits&lt;_ForwardIterator1&gt;::value_type,
<span class="lineNum">    4030 </span>            :             typename iterator_traits&lt;_ForwardIterator2&gt;::value_type&gt;)
<span class="lineNum">    4031 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    4032 </span>            :       __glibcxx_requires_valid_range(__first2, __last2);
<span class="lineNum">    4033 </span>            : 
<span class="lineNum">    4034 </span>            :       return std::__search(__first1, __last1, __first2, __last2,
<span class="lineNum">    4035 </span>            :                            __gnu_cxx::__ops::__iter_equal_to_iter());
<span class="lineNum">    4036 </span>            :     }
<span class="lineNum">    4037 </span>            : 
<span class="lineNum">    4038 </span>            :   /**
<span class="lineNum">    4039 </span>            :    *  @brief Search a sequence for a matching sub-sequence using a predicate.
<span class="lineNum">    4040 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    4041 </span>            :    *  @param  __first1     A forward iterator.
<span class="lineNum">    4042 </span>            :    *  @param  __last1      A forward iterator.
<span class="lineNum">    4043 </span>            :    *  @param  __first2     A forward iterator.
<span class="lineNum">    4044 </span>            :    *  @param  __last2      A forward iterator.
<span class="lineNum">    4045 </span>            :    *  @param  __predicate  A binary predicate.
<span class="lineNum">    4046 </span>            :    *  @return   The first iterator @c i in the range
<span class="lineNum">    4047 </span>            :    *  @p [__first1,__last1-(__last2-__first2)) such that
<span class="lineNum">    4048 </span>            :    *  @p __predicate(*(i+N),*(__first2+N)) is true for each @c N in the range
<span class="lineNum">    4049 </span>            :    *  @p [0,__last2-__first2), or @p __last1 if no such iterator exists.
<span class="lineNum">    4050 </span>            :    *
<span class="lineNum">    4051 </span>            :    *  Searches the range @p [__first1,__last1) for a sub-sequence that
<span class="lineNum">    4052 </span>            :    *  compares equal value-by-value with the sequence given by @p
<span class="lineNum">    4053 </span>            :    *  [__first2,__last2), using @p __predicate to determine equality,
<span class="lineNum">    4054 </span>            :    *  and returns an iterator to the first element of the
<span class="lineNum">    4055 </span>            :    *  sub-sequence, or @p __last1 if no such iterator exists.
<span class="lineNum">    4056 </span>            :    *
<span class="lineNum">    4057 </span>            :    *  @see search(_ForwardIter1, _ForwardIter1, _ForwardIter2, _ForwardIter2)
<span class="lineNum">    4058 </span>            :   */
<span class="lineNum">    4059 </span>            :   template&lt;typename _ForwardIterator1, typename _ForwardIterator2,
<span class="lineNum">    4060 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    4061 </span>            :     inline _ForwardIterator1
<span class="lineNum">    4062 </span>            :     search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
<span class="lineNum">    4063 </span>            :            _ForwardIterator2 __first2, _ForwardIterator2 __last2,
<span class="lineNum">    4064 </span>            :            _BinaryPredicate  __predicate)
<span class="lineNum">    4065 </span>            :     {
<span class="lineNum">    4066 </span>            :       // concept requirements
<span class="lineNum">    4067 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator1&gt;)
<span class="lineNum">    4068 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator2&gt;)
<span class="lineNum">    4069 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    4070 </span>            :             typename iterator_traits&lt;_ForwardIterator1&gt;::value_type,
<span class="lineNum">    4071 </span>            :             typename iterator_traits&lt;_ForwardIterator2&gt;::value_type&gt;)
<span class="lineNum">    4072 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    4073 </span>            :       __glibcxx_requires_valid_range(__first2, __last2);
<span class="lineNum">    4074 </span>            : 
<span class="lineNum">    4075 </span>            :       return std::__search(__first1, __last1, __first2, __last2,
<span class="lineNum">    4076 </span>            :                            __gnu_cxx::__ops::__iter_comp_iter(__predicate));
<span class="lineNum">    4077 </span>            :     }
<span class="lineNum">    4078 </span>            : 
<span class="lineNum">    4079 </span>            :   /**
<span class="lineNum">    4080 </span>            :    *  @brief Search a sequence for a number of consecutive values.
<span class="lineNum">    4081 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    4082 </span>            :    *  @param  __first  A forward iterator.
<span class="lineNum">    4083 </span>            :    *  @param  __last   A forward iterator.
<span class="lineNum">    4084 </span>            :    *  @param  __count  The number of consecutive values.
<span class="lineNum">    4085 </span>            :    *  @param  __val    The value to find.
<span class="lineNum">    4086 </span>            :    *  @return The first iterator @c i in the range @p
<span class="lineNum">    4087 </span>            :    *  [__first,__last-__count) such that @c *(i+N) == @p __val for
<span class="lineNum">    4088 </span>            :    *  each @c N in the range @p [0,__count), or @p __last if no such
<span class="lineNum">    4089 </span>            :    *  iterator exists.
<span class="lineNum">    4090 </span>            :    *
<span class="lineNum">    4091 </span>            :    *  Searches the range @p [__first,__last) for @p count consecutive elements
<span class="lineNum">    4092 </span>            :    *  equal to @p __val.
<span class="lineNum">    4093 </span>            :   */
<span class="lineNum">    4094 </span>            :   template&lt;typename _ForwardIterator, typename _Integer, typename _Tp&gt;
<span class="lineNum">    4095 </span>            :     inline _ForwardIterator
<span class="lineNum">    4096 </span>            :     search_n(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    4097 </span>            :              _Integer __count, const _Tp&amp; __val)
<span class="lineNum">    4098 </span>            :     {
<span class="lineNum">    4099 </span>            :       // concept requirements
<span class="lineNum">    4100 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    4101 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">    4102 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type, _Tp&gt;)
<span class="lineNum">    4103 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4104 </span>            : 
<span class="lineNum">    4105 </span>            :       return std::__search_n(__first, __last, __count,
<span class="lineNum">    4106 </span>            :                              __gnu_cxx::__ops::__iter_equals_val(__val));
<span class="lineNum">    4107 </span>            :     }
<span class="lineNum">    4108 </span>            : 
<span class="lineNum">    4109 </span>            : 
<span class="lineNum">    4110 </span>            :   /**
<span class="lineNum">    4111 </span>            :    *  @brief Search a sequence for a number of consecutive values using a
<span class="lineNum">    4112 </span>            :    *         predicate.
<span class="lineNum">    4113 </span>            :    *  @ingroup non_mutating_algorithms
<span class="lineNum">    4114 </span>            :    *  @param  __first        A forward iterator.
<span class="lineNum">    4115 </span>            :    *  @param  __last         A forward iterator.
<span class="lineNum">    4116 </span>            :    *  @param  __count        The number of consecutive values.
<span class="lineNum">    4117 </span>            :    *  @param  __val          The value to find.
<span class="lineNum">    4118 </span>            :    *  @param  __binary_pred  A binary predicate.
<span class="lineNum">    4119 </span>            :    *  @return The first iterator @c i in the range @p
<span class="lineNum">    4120 </span>            :    *  [__first,__last-__count) such that @p
<span class="lineNum">    4121 </span>            :    *  __binary_pred(*(i+N),__val) is true for each @c N in the range
<span class="lineNum">    4122 </span>            :    *  @p [0,__count), or @p __last if no such iterator exists.
<span class="lineNum">    4123 </span>            :    *
<span class="lineNum">    4124 </span>            :    *  Searches the range @p [__first,__last) for @p __count
<span class="lineNum">    4125 </span>            :    *  consecutive elements for which the predicate returns true.
<span class="lineNum">    4126 </span>            :   */
<span class="lineNum">    4127 </span>            :   template&lt;typename _ForwardIterator, typename _Integer, typename _Tp,
<span class="lineNum">    4128 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    4129 </span>            :     inline _ForwardIterator
<span class="lineNum">    4130 </span>            :     search_n(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    4131 </span>            :              _Integer __count, const _Tp&amp; __val,
<span class="lineNum">    4132 </span>            :              _BinaryPredicate __binary_pred)
<span class="lineNum">    4133 </span>            :     {
<span class="lineNum">    4134 </span>            :       // concept requirements
<span class="lineNum">    4135 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    4136 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_BinaryPredicate,
<span class="lineNum">    4137 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type, _Tp&gt;)
<span class="lineNum">    4138 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4139 </span>            : 
<span class="lineNum">    4140 </span>            :       return std::__search_n(__first, __last, __count,
<span class="lineNum">    4141 </span>            :                 __gnu_cxx::__ops::__iter_comp_val(__binary_pred, __val));
<span class="lineNum">    4142 </span>            :     }
<span class="lineNum">    4143 </span>            : 
<span class="lineNum">    4144 </span>            : 
<span class="lineNum">    4145 </span>            :   /**
<span class="lineNum">    4146 </span>            :    *  @brief Perform an operation on a sequence.
<span class="lineNum">    4147 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4148 </span>            :    *  @param  __first     An input iterator.
<span class="lineNum">    4149 </span>            :    *  @param  __last      An input iterator.
<span class="lineNum">    4150 </span>            :    *  @param  __result    An output iterator.
<span class="lineNum">    4151 </span>            :    *  @param  __unary_op  A unary operator.
<span class="lineNum">    4152 </span>            :    *  @return   An output iterator equal to @p __result+(__last-__first).
<span class="lineNum">    4153 </span>            :    *
<span class="lineNum">    4154 </span>            :    *  Applies the operator to each element in the input range and assigns
<span class="lineNum">    4155 </span>            :    *  the results to successive elements of the output sequence.
<span class="lineNum">    4156 </span>            :    *  Evaluates @p *(__result+N)=unary_op(*(__first+N)) for each @c N in the
<span class="lineNum">    4157 </span>            :    *  range @p [0,__last-__first).
<span class="lineNum">    4158 </span>            :    *
<span class="lineNum">    4159 </span>            :    *  @p unary_op must not alter its argument.
<span class="lineNum">    4160 </span>            :   */
<span class="lineNum">    4161 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">    4162 </span>            :            typename _UnaryOperation&gt;
<span class="lineNum">    4163 </span>            :     _OutputIterator
<span class="lineNum">    4164 </span>            :     transform(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    4165 </span>            :               _OutputIterator __result, _UnaryOperation __unary_op)
<span class="lineNum">    4166 </span>            :     {
<span class="lineNum">    4167 </span>            :       // concept requirements
<span class="lineNum">    4168 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    4169 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4170 </span>            :             // &quot;the type returned by a _UnaryOperation&quot;
<span class="lineNum">    4171 </span>            :             __typeof__(__unary_op(*__first))&gt;)
<span class="lineNum">    4172 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4173 </span>            : 
<span class="lineNum">    4174 </span><span class="lineNoCov">          0 :       for (; __first != __last; ++__first, ++__result)</span>
<span class="lineNum">    4175 </span><span class="lineNoCov">          0 :         *__result = __unary_op(*__first);</span>
<span class="lineNum">    4176 </span>            :       return __result;
<span class="lineNum">    4177 </span>            :     }
<span class="lineNum">    4178 </span>            : 
<span class="lineNum">    4179 </span>            :   /**
<span class="lineNum">    4180 </span>            :    *  @brief Perform an operation on corresponding elements of two sequences.
<span class="lineNum">    4181 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4182 </span>            :    *  @param  __first1     An input iterator.
<span class="lineNum">    4183 </span>            :    *  @param  __last1      An input iterator.
<span class="lineNum">    4184 </span>            :    *  @param  __first2     An input iterator.
<span class="lineNum">    4185 </span>            :    *  @param  __result     An output iterator.
<span class="lineNum">    4186 </span>            :    *  @param  __binary_op  A binary operator.
<span class="lineNum">    4187 </span>            :    *  @return   An output iterator equal to @p result+(last-first).
<span class="lineNum">    4188 </span>            :    *
<span class="lineNum">    4189 </span>            :    *  Applies the operator to the corresponding elements in the two
<span class="lineNum">    4190 </span>            :    *  input ranges and assigns the results to successive elements of the
<span class="lineNum">    4191 </span>            :    *  output sequence.
<span class="lineNum">    4192 </span>            :    *  Evaluates @p
<span class="lineNum">    4193 </span>            :    *  *(__result+N)=__binary_op(*(__first1+N),*(__first2+N)) for each
<span class="lineNum">    4194 </span>            :    *  @c N in the range @p [0,__last1-__first1).
<span class="lineNum">    4195 </span>            :    *
<span class="lineNum">    4196 </span>            :    *  @p binary_op must not alter either of its arguments.
<span class="lineNum">    4197 </span>            :   */
<span class="lineNum">    4198 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    4199 </span>            :            typename _OutputIterator, typename _BinaryOperation&gt;
<span class="lineNum">    4200 </span>            :     _OutputIterator
<span class="lineNum">    4201 </span>            :     transform(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    4202 </span>            :               _InputIterator2 __first2, _OutputIterator __result,
<span class="lineNum">    4203 </span>            :               _BinaryOperation __binary_op)
<span class="lineNum">    4204 </span>            :     {
<span class="lineNum">    4205 </span>            :       // concept requirements
<span class="lineNum">    4206 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    4207 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    4208 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4209 </span>            :             // &quot;the type returned by a _BinaryOperation&quot;
<span class="lineNum">    4210 </span>            :             __typeof__(__binary_op(*__first1,*__first2))&gt;)
<span class="lineNum">    4211 </span>            :       __glibcxx_requires_valid_range(__first1, __last1);
<span class="lineNum">    4212 </span>            : 
<span class="lineNum">    4213 </span>            :       for (; __first1 != __last1; ++__first1, ++__first2, ++__result)
<span class="lineNum">    4214 </span>            :         *__result = __binary_op(*__first1, *__first2);
<span class="lineNum">    4215 </span>            :       return __result;
<span class="lineNum">    4216 </span>            :     }
<span class="lineNum">    4217 </span>            : 
<span class="lineNum">    4218 </span>            :   /**
<span class="lineNum">    4219 </span>            :    *  @brief Replace each occurrence of one value in a sequence with another
<span class="lineNum">    4220 </span>            :    *         value.
<span class="lineNum">    4221 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4222 </span>            :    *  @param  __first      A forward iterator.
<span class="lineNum">    4223 </span>            :    *  @param  __last       A forward iterator.
<span class="lineNum">    4224 </span>            :    *  @param  __old_value  The value to be replaced.
<span class="lineNum">    4225 </span>            :    *  @param  __new_value  The replacement value.
<span class="lineNum">    4226 </span>            :    *  @return   replace() returns no value.
<span class="lineNum">    4227 </span>            :    *
<span class="lineNum">    4228 </span>            :    *  For each iterator @c i in the range @p [__first,__last) if @c *i ==
<span class="lineNum">    4229 </span>            :    *  @p __old_value then the assignment @c *i = @p __new_value is performed.
<span class="lineNum">    4230 </span>            :   */
<span class="lineNum">    4231 </span>            :   template&lt;typename _ForwardIterator, typename _Tp&gt;
<span class="lineNum">    4232 </span>            :     void
<span class="lineNum">    4233 </span>            :     replace(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    4234 </span>            :             const _Tp&amp; __old_value, const _Tp&amp; __new_value)
<span class="lineNum">    4235 </span>            :     {
<span class="lineNum">    4236 </span>            :       // concept requirements
<span class="lineNum">    4237 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">    4238 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">    4239 </span>            :       __glibcxx_function_requires(_EqualOpConcept&lt;
<span class="lineNum">    4240 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type, _Tp&gt;)
<span class="lineNum">    4241 </span>            :       __glibcxx_function_requires(_ConvertibleConcept&lt;_Tp,
<span class="lineNum">    4242 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    4243 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4244 </span>            : 
<span class="lineNum">    4245 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">    4246 </span>            :         if (*__first == __old_value)
<span class="lineNum">    4247 </span>            :           *__first = __new_value;
<span class="lineNum">    4248 </span>            :     }
<span class="lineNum">    4249 </span>            : 
<span class="lineNum">    4250 </span>            :   /**
<span class="lineNum">    4251 </span>            :    *  @brief Replace each value in a sequence for which a predicate returns
<span class="lineNum">    4252 </span>            :    *         true with another value.
<span class="lineNum">    4253 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4254 </span>            :    *  @param  __first      A forward iterator.
<span class="lineNum">    4255 </span>            :    *  @param  __last       A forward iterator.
<span class="lineNum">    4256 </span>            :    *  @param  __pred       A predicate.
<span class="lineNum">    4257 </span>            :    *  @param  __new_value  The replacement value.
<span class="lineNum">    4258 </span>            :    *  @return   replace_if() returns no value.
<span class="lineNum">    4259 </span>            :    *
<span class="lineNum">    4260 </span>            :    *  For each iterator @c i in the range @p [__first,__last) if @p __pred(*i)
<span class="lineNum">    4261 </span>            :    *  is true then the assignment @c *i = @p __new_value is performed.
<span class="lineNum">    4262 </span>            :   */
<span class="lineNum">    4263 </span>            :   template&lt;typename _ForwardIterator, typename _Predicate, typename _Tp&gt;
<span class="lineNum">    4264 </span>            :     void
<span class="lineNum">    4265 </span>            :     replace_if(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    4266 </span>            :                _Predicate __pred, const _Tp&amp; __new_value)
<span class="lineNum">    4267 </span>            :     {
<span class="lineNum">    4268 </span>            :       // concept requirements
<span class="lineNum">    4269 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">    4270 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">    4271 </span>            :       __glibcxx_function_requires(_ConvertibleConcept&lt;_Tp,
<span class="lineNum">    4272 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    4273 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">    4274 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    4275 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4276 </span>            : 
<span class="lineNum">    4277 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">    4278 </span>            :         if (__pred(*__first))
<span class="lineNum">    4279 </span>            :           *__first = __new_value;
<span class="lineNum">    4280 </span>            :     }
<span class="lineNum">    4281 </span>            : 
<span class="lineNum">    4282 </span>            :   /**
<span class="lineNum">    4283 </span>            :    *  @brief Assign the result of a function object to each value in a
<span class="lineNum">    4284 </span>            :    *         sequence.
<span class="lineNum">    4285 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4286 </span>            :    *  @param  __first  A forward iterator.
<span class="lineNum">    4287 </span>            :    *  @param  __last   A forward iterator.
<span class="lineNum">    4288 </span>            :    *  @param  __gen    A function object taking no arguments and returning
<span class="lineNum">    4289 </span>            :    *                 std::iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    4290 </span>            :    *  @return   generate() returns no value.
<span class="lineNum">    4291 </span>            :    *
<span class="lineNum">    4292 </span>            :    *  Performs the assignment @c *i = @p __gen() for each @c i in the range
<span class="lineNum">    4293 </span>            :    *  @p [__first,__last).
<span class="lineNum">    4294 </span>            :   */
<span class="lineNum">    4295 </span>            :   template&lt;typename _ForwardIterator, typename _Generator&gt;
<span class="lineNum">    4296 </span>            :     void
<span class="lineNum">    4297 </span>            :     generate(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    4298 </span>            :              _Generator __gen)
<span class="lineNum">    4299 </span>            :     {
<span class="lineNum">    4300 </span>            :       // concept requirements
<span class="lineNum">    4301 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    4302 </span>            :       __glibcxx_function_requires(_GeneratorConcept&lt;_Generator,
<span class="lineNum">    4303 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    4304 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4305 </span>            : 
<span class="lineNum">    4306 </span>            :       for (; __first != __last; ++__first)
<span class="lineNum">    4307 </span>            :         *__first = __gen();
<span class="lineNum">    4308 </span>            :     }
<span class="lineNum">    4309 </span>            : 
<span class="lineNum">    4310 </span>            :   /**
<span class="lineNum">    4311 </span>            :    *  @brief Assign the result of a function object to each value in a
<span class="lineNum">    4312 </span>            :    *         sequence.
<span class="lineNum">    4313 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4314 </span>            :    *  @param  __first  A forward iterator.
<span class="lineNum">    4315 </span>            :    *  @param  __n      The length of the sequence.
<span class="lineNum">    4316 </span>            :    *  @param  __gen    A function object taking no arguments and returning
<span class="lineNum">    4317 </span>            :    *                 std::iterator_traits&lt;_ForwardIterator&gt;::value_type
<span class="lineNum">    4318 </span>            :    *  @return   The end of the sequence, @p __first+__n
<span class="lineNum">    4319 </span>            :    *
<span class="lineNum">    4320 </span>            :    *  Performs the assignment @c *i = @p __gen() for each @c i in the range
<span class="lineNum">    4321 </span>            :    *  @p [__first,__first+__n).
<span class="lineNum">    4322 </span>            :    *
<span class="lineNum">    4323 </span>            :    *  _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">    4324 </span>            :    *  DR 865. More algorithms that throw away information
<span class="lineNum">    4325 </span>            :   */
<span class="lineNum">    4326 </span>            :   template&lt;typename _OutputIterator, typename _Size, typename _Generator&gt;
<span class="lineNum">    4327 </span>            :     _OutputIterator
<span class="lineNum">    4328 </span>            :     generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
<span class="lineNum">    4329 </span>            :     {
<span class="lineNum">    4330 </span>            :       // concept requirements
<span class="lineNum">    4331 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4332 </span>            :             // &quot;the type returned by a _Generator&quot;
<span class="lineNum">    4333 </span>            :             __typeof__(__gen())&gt;)
<span class="lineNum">    4334 </span>            : 
<span class="lineNum">    4335 </span>            :       for (__decltype(__n + 0) __niter = __n;
<span class="lineNum">    4336 </span>            :            __niter &gt; 0; --__niter, ++__first)
<span class="lineNum">    4337 </span>            :         *__first = __gen();
<span class="lineNum">    4338 </span>            :       return __first;
<span class="lineNum">    4339 </span>            :     }
<span class="lineNum">    4340 </span>            : 
<span class="lineNum">    4341 </span>            :   /**
<span class="lineNum">    4342 </span>            :    *  @brief Copy a sequence, removing consecutive duplicate values.
<span class="lineNum">    4343 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4344 </span>            :    *  @param  __first   An input iterator.
<span class="lineNum">    4345 </span>            :    *  @param  __last    An input iterator.
<span class="lineNum">    4346 </span>            :    *  @param  __result  An output iterator.
<span class="lineNum">    4347 </span>            :    *  @return   An iterator designating the end of the resulting sequence.
<span class="lineNum">    4348 </span>            :    *
<span class="lineNum">    4349 </span>            :    *  Copies each element in the range @p [__first,__last) to the range
<span class="lineNum">    4350 </span>            :    *  beginning at @p __result, except that only the first element is copied
<span class="lineNum">    4351 </span>            :    *  from groups of consecutive elements that compare equal.
<span class="lineNum">    4352 </span>            :    *  unique_copy() is stable, so the relative order of elements that are
<span class="lineNum">    4353 </span>            :    *  copied is unchanged.
<span class="lineNum">    4354 </span>            :    *
<span class="lineNum">    4355 </span>            :    *  _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">    4356 </span>            :    *  DR 241. Does unique_copy() require CopyConstructible and Assignable?
<span class="lineNum">    4357 </span>            :    *  
<span class="lineNum">    4358 </span>            :    *  _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">    4359 </span>            :    *  DR 538. 241 again: Does unique_copy() require CopyConstructible and 
<span class="lineNum">    4360 </span>            :    *  Assignable?
<span class="lineNum">    4361 </span>            :   */
<span class="lineNum">    4362 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator&gt;
<span class="lineNum">    4363 </span>            :     inline _OutputIterator
<span class="lineNum">    4364 </span>            :     unique_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    4365 </span>            :                 _OutputIterator __result)
<span class="lineNum">    4366 </span>            :     {
<span class="lineNum">    4367 </span>            :       // concept requirements
<span class="lineNum">    4368 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    4369 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4370 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    4371 </span>            :       __glibcxx_function_requires(_EqualityComparableConcept&lt;
<span class="lineNum">    4372 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    4373 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4374 </span>            : 
<span class="lineNum">    4375 </span>            :       if (__first == __last)
<span class="lineNum">    4376 </span>            :         return __result;
<span class="lineNum">    4377 </span>            :       return std::__unique_copy(__first, __last, __result,
<span class="lineNum">    4378 </span>            :                                 __gnu_cxx::__ops::__iter_equal_to_iter(),
<span class="lineNum">    4379 </span>            :                                 std::__iterator_category(__first),
<span class="lineNum">    4380 </span>            :                                 std::__iterator_category(__result));
<span class="lineNum">    4381 </span>            :     }
<span class="lineNum">    4382 </span>            : 
<span class="lineNum">    4383 </span>            :   /**
<span class="lineNum">    4384 </span>            :    *  @brief Copy a sequence, removing consecutive values using a predicate.
<span class="lineNum">    4385 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4386 </span>            :    *  @param  __first        An input iterator.
<span class="lineNum">    4387 </span>            :    *  @param  __last         An input iterator.
<span class="lineNum">    4388 </span>            :    *  @param  __result       An output iterator.
<span class="lineNum">    4389 </span>            :    *  @param  __binary_pred  A binary predicate.
<span class="lineNum">    4390 </span>            :    *  @return   An iterator designating the end of the resulting sequence.
<span class="lineNum">    4391 </span>            :    *
<span class="lineNum">    4392 </span>            :    *  Copies each element in the range @p [__first,__last) to the range
<span class="lineNum">    4393 </span>            :    *  beginning at @p __result, except that only the first element is copied
<span class="lineNum">    4394 </span>            :    *  from groups of consecutive elements for which @p __binary_pred returns
<span class="lineNum">    4395 </span>            :    *  true.
<span class="lineNum">    4396 </span>            :    *  unique_copy() is stable, so the relative order of elements that are
<span class="lineNum">    4397 </span>            :    *  copied is unchanged.
<span class="lineNum">    4398 </span>            :    *
<span class="lineNum">    4399 </span>            :    *  _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">    4400 </span>            :    *  DR 241. Does unique_copy() require CopyConstructible and Assignable?
<span class="lineNum">    4401 </span>            :   */
<span class="lineNum">    4402 </span>            :   template&lt;typename _InputIterator, typename _OutputIterator,
<span class="lineNum">    4403 </span>            :            typename _BinaryPredicate&gt;
<span class="lineNum">    4404 </span>            :     inline _OutputIterator
<span class="lineNum">    4405 </span>            :     unique_copy(_InputIterator __first, _InputIterator __last,
<span class="lineNum">    4406 </span>            :                 _OutputIterator __result,
<span class="lineNum">    4407 </span>            :                 _BinaryPredicate __binary_pred)
<span class="lineNum">    4408 </span>            :     {
<span class="lineNum">    4409 </span>            :       // concept requirements -- predicates checked later
<span class="lineNum">    4410 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator&gt;)
<span class="lineNum">    4411 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4412 </span>            :             typename iterator_traits&lt;_InputIterator&gt;::value_type&gt;)
<span class="lineNum">    4413 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4414 </span>            : 
<span class="lineNum">    4415 </span>            :       if (__first == __last)
<span class="lineNum">    4416 </span>            :         return __result;
<span class="lineNum">    4417 </span>            :       return std::__unique_copy(__first, __last, __result,
<span class="lineNum">    4418 </span>            :                         __gnu_cxx::__ops::__iter_comp_iter(__binary_pred),
<span class="lineNum">    4419 </span>            :                                 std::__iterator_category(__first),
<span class="lineNum">    4420 </span>            :                                 std::__iterator_category(__result));
<span class="lineNum">    4421 </span>            :     }
<span class="lineNum">    4422 </span>            : 
<span class="lineNum">    4423 </span>            :   /**
<span class="lineNum">    4424 </span>            :    *  @brief Randomly shuffle the elements of a sequence.
<span class="lineNum">    4425 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4426 </span>            :    *  @param  __first   A forward iterator.
<span class="lineNum">    4427 </span>            :    *  @param  __last    A forward iterator.
<span class="lineNum">    4428 </span>            :    *  @return  Nothing.
<span class="lineNum">    4429 </span>            :    *
<span class="lineNum">    4430 </span>            :    *  Reorder the elements in the range @p [__first,__last) using a random
<span class="lineNum">    4431 </span>            :    *  distribution, so that every possible ordering of the sequence is
<span class="lineNum">    4432 </span>            :    *  equally likely.
<span class="lineNum">    4433 </span>            :   */
<a name="4434"><span class="lineNum">    4434 </span>            :   template&lt;typename _RandomAccessIterator&gt;</a>
<span class="lineNum">    4435 </span>            :     inline void
<span class="lineNum">    4436 </span><span class="lineNoCov">          0 :     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)</span>
<span class="lineNum">    4437 </span>            :     {
<span class="lineNum">    4438 </span>            :       // concept requirements
<span class="lineNum">    4439 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4440 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    4441 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4442 </span>            : 
<span class="lineNum">    4443 </span><span class="lineNoCov">          0 :       if (__first != __last)</span>
<span class="lineNum">    4444 </span><span class="lineNoCov">          0 :         for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)</span>
<span class="lineNum">    4445 </span>            :           {
<span class="lineNum">    4446 </span>            :             // XXX rand() % N is not uniformly distributed
<span class="lineNum">    4447 </span>            :             _RandomAccessIterator __j = __first
<span class="lineNum">    4448 </span><span class="lineNoCov">          0 :                                         + std::rand() % ((__i - __first) + 1);</span>
<span class="lineNum">    4449 </span><span class="lineNoCov">          0 :             if (__i != __j)</span>
<span class="lineNum">    4450 </span>            :               std::iter_swap(__i, __j);
<span class="lineNum">    4451 </span>            :           }
<span class="lineNum">    4452 </span><span class="lineNoCov">          0 :     }</span>
<span class="lineNum">    4453 </span>            : 
<span class="lineNum">    4454 </span>            :   /**
<span class="lineNum">    4455 </span>            :    *  @brief Shuffle the elements of a sequence using a random number
<span class="lineNum">    4456 </span>            :    *         generator.
<span class="lineNum">    4457 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4458 </span>            :    *  @param  __first   A forward iterator.
<span class="lineNum">    4459 </span>            :    *  @param  __last    A forward iterator.
<span class="lineNum">    4460 </span>            :    *  @param  __rand    The RNG functor or function.
<span class="lineNum">    4461 </span>            :    *  @return  Nothing.
<span class="lineNum">    4462 </span>            :    *
<span class="lineNum">    4463 </span>            :    *  Reorders the elements in the range @p [__first,__last) using @p __rand to
<span class="lineNum">    4464 </span>            :    *  provide a random distribution. Calling @p __rand(N) for a positive
<span class="lineNum">    4465 </span>            :    *  integer @p N should return a randomly chosen integer from the
<span class="lineNum">    4466 </span>            :    *  range [0,N).
<span class="lineNum">    4467 </span>            :   */
<span class="lineNum">    4468 </span>            :   template&lt;typename _RandomAccessIterator, typename _RandomNumberGenerator&gt;
<span class="lineNum">    4469 </span>            :     void
<span class="lineNum">    4470 </span>            :     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
<span class="lineNum">    4471 </span>            : #if __cplusplus &gt;= 201103L
<span class="lineNum">    4472 </span>            :                    _RandomNumberGenerator&amp;&amp; __rand)
<span class="lineNum">    4473 </span>            : #else
<span class="lineNum">    4474 </span>            :                    _RandomNumberGenerator&amp; __rand)
<span class="lineNum">    4475 </span>            : #endif
<span class="lineNum">    4476 </span>            :     {
<span class="lineNum">    4477 </span>            :       // concept requirements
<span class="lineNum">    4478 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4479 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    4480 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4481 </span>            : 
<span class="lineNum">    4482 </span>            :       if (__first == __last)
<span class="lineNum">    4483 </span>            :         return;
<span class="lineNum">    4484 </span>            :       for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
<span class="lineNum">    4485 </span>            :         {
<span class="lineNum">    4486 </span>            :           _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
<span class="lineNum">    4487 </span>            :           if (__i != __j)
<span class="lineNum">    4488 </span>            :             std::iter_swap(__i, __j);
<span class="lineNum">    4489 </span>            :         }
<span class="lineNum">    4490 </span>            :     }
<span class="lineNum">    4491 </span>            : 
<span class="lineNum">    4492 </span>            : 
<span class="lineNum">    4493 </span>            :   /**
<span class="lineNum">    4494 </span>            :    *  @brief Move elements for which a predicate is true to the beginning
<span class="lineNum">    4495 </span>            :    *         of a sequence.
<span class="lineNum">    4496 </span>            :    *  @ingroup mutating_algorithms
<span class="lineNum">    4497 </span>            :    *  @param  __first   A forward iterator.
<span class="lineNum">    4498 </span>            :    *  @param  __last    A forward iterator.
<span class="lineNum">    4499 </span>            :    *  @param  __pred    A predicate functor.
<span class="lineNum">    4500 </span>            :    *  @return  An iterator @p middle such that @p __pred(i) is true for each
<span class="lineNum">    4501 </span>            :    *  iterator @p i in the range @p [__first,middle) and false for each @p i
<span class="lineNum">    4502 </span>            :    *  in the range @p [middle,__last).
<span class="lineNum">    4503 </span>            :    *
<span class="lineNum">    4504 </span>            :    *  @p __pred must not modify its operand. @p partition() does not preserve
<span class="lineNum">    4505 </span>            :    *  the relative ordering of elements in each group, use
<span class="lineNum">    4506 </span>            :    *  @p stable_partition() if this is needed.
<span class="lineNum">    4507 </span>            :   */
<span class="lineNum">    4508 </span>            :   template&lt;typename _ForwardIterator, typename _Predicate&gt;
<span class="lineNum">    4509 </span>            :     inline _ForwardIterator
<span class="lineNum">    4510 </span>            :     partition(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    4511 </span>            :               _Predicate   __pred)
<span class="lineNum">    4512 </span>            :     {
<span class="lineNum">    4513 </span>            :       // concept requirements
<span class="lineNum">    4514 </span>            :       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept&lt;
<span class="lineNum">    4515 </span>            :                                   _ForwardIterator&gt;)
<span class="lineNum">    4516 </span>            :       __glibcxx_function_requires(_UnaryPredicateConcept&lt;_Predicate,
<span class="lineNum">    4517 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    4518 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4519 </span>            : 
<span class="lineNum">    4520 </span>            :       return std::__partition(__first, __last, __pred,
<span class="lineNum">    4521 </span>            :                               std::__iterator_category(__first));
<span class="lineNum">    4522 </span>            :     }
<span class="lineNum">    4523 </span>            : 
<span class="lineNum">    4524 </span>            : 
<span class="lineNum">    4525 </span>            :   /**
<span class="lineNum">    4526 </span>            :    *  @brief Sort the smallest elements of a sequence.
<span class="lineNum">    4527 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4528 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    4529 </span>            :    *  @param  __middle  Another iterator.
<span class="lineNum">    4530 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    4531 </span>            :    *  @return  Nothing.
<span class="lineNum">    4532 </span>            :    *
<span class="lineNum">    4533 </span>            :    *  Sorts the smallest @p (__middle-__first) elements in the range
<span class="lineNum">    4534 </span>            :    *  @p [first,last) and moves them to the range @p [__first,__middle). The
<span class="lineNum">    4535 </span>            :    *  order of the remaining elements in the range @p [__middle,__last) is
<span class="lineNum">    4536 </span>            :    *  undefined.
<span class="lineNum">    4537 </span>            :    *  After the sort if @e i and @e j are iterators in the range
<span class="lineNum">    4538 </span>            :    *  @p [__first,__middle) such that i precedes j and @e k is an iterator in
<span class="lineNum">    4539 </span>            :    *  the range @p [__middle,__last) then *j&lt;*i and *k&lt;*i are both false.
<span class="lineNum">    4540 </span>            :   */
<span class="lineNum">    4541 </span>            :   template&lt;typename _RandomAccessIterator&gt;
<span class="lineNum">    4542 </span>            :     inline void
<span class="lineNum">    4543 </span>            :     partial_sort(_RandomAccessIterator __first,
<span class="lineNum">    4544 </span>            :                  _RandomAccessIterator __middle,
<span class="lineNum">    4545 </span>            :                  _RandomAccessIterator __last)
<span class="lineNum">    4546 </span>            :     {
<span class="lineNum">    4547 </span>            :       // concept requirements
<span class="lineNum">    4548 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4549 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    4550 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    4551 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type&gt;)
<span class="lineNum">    4552 </span>            :       __glibcxx_requires_valid_range(__first, __middle);
<span class="lineNum">    4553 </span>            :       __glibcxx_requires_valid_range(__middle, __last);
<span class="lineNum">    4554 </span>            : 
<span class="lineNum">    4555 </span>            :       std::__partial_sort(__first, __middle, __last,
<span class="lineNum">    4556 </span>            :                           __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    4557 </span>            :     }
<span class="lineNum">    4558 </span>            : 
<span class="lineNum">    4559 </span>            :   /**
<span class="lineNum">    4560 </span>            :    *  @brief Sort the smallest elements of a sequence using a predicate
<span class="lineNum">    4561 </span>            :    *         for comparison.
<span class="lineNum">    4562 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4563 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    4564 </span>            :    *  @param  __middle  Another iterator.
<span class="lineNum">    4565 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    4566 </span>            :    *  @param  __comp    A comparison functor.
<span class="lineNum">    4567 </span>            :    *  @return  Nothing.
<span class="lineNum">    4568 </span>            :    *
<span class="lineNum">    4569 </span>            :    *  Sorts the smallest @p (__middle-__first) elements in the range
<span class="lineNum">    4570 </span>            :    *  @p [__first,__last) and moves them to the range @p [__first,__middle). The
<span class="lineNum">    4571 </span>            :    *  order of the remaining elements in the range @p [__middle,__last) is
<span class="lineNum">    4572 </span>            :    *  undefined.
<span class="lineNum">    4573 </span>            :    *  After the sort if @e i and @e j are iterators in the range
<span class="lineNum">    4574 </span>            :    *  @p [__first,__middle) such that i precedes j and @e k is an iterator in
<span class="lineNum">    4575 </span>            :    *  the range @p [__middle,__last) then @p *__comp(j,*i) and @p __comp(*k,*i)
<span class="lineNum">    4576 </span>            :    *  are both false.
<span class="lineNum">    4577 </span>            :   */
<a name="4578"><span class="lineNum">    4578 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;</a>
<span class="lineNum">    4579 </span>            :     inline void
<span class="lineNum">    4580 </span><span class="lineNoCov">          0 :     partial_sort(_RandomAccessIterator __first,</span>
<span class="lineNum">    4581 </span>            :                  _RandomAccessIterator __middle,
<span class="lineNum">    4582 </span>            :                  _RandomAccessIterator __last,
<span class="lineNum">    4583 </span>            :                  _Compare __comp)
<span class="lineNum">    4584 </span>            :     {
<span class="lineNum">    4585 </span>            :       // concept requirements
<span class="lineNum">    4586 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4587 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    4588 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    4589 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type,
<span class="lineNum">    4590 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type&gt;)
<span class="lineNum">    4591 </span>            :       __glibcxx_requires_valid_range(__first, __middle);
<span class="lineNum">    4592 </span>            :       __glibcxx_requires_valid_range(__middle, __last);
<span class="lineNum">    4593 </span>            : 
<span class="lineNum">    4594 </span><span class="lineNoCov">          0 :       std::__partial_sort(__first, __middle, __last,</span>
<span class="lineNum">    4595 </span>            :                           __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    4596 </span><span class="lineNoCov">          0 :     }</span>
<span class="lineNum">    4597 </span>            : 
<span class="lineNum">    4598 </span>            :   /**
<span class="lineNum">    4599 </span>            :    *  @brief Sort a sequence just enough to find a particular position.
<span class="lineNum">    4600 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4601 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    4602 </span>            :    *  @param  __nth     Another iterator.
<span class="lineNum">    4603 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    4604 </span>            :    *  @return  Nothing.
<span class="lineNum">    4605 </span>            :    *
<span class="lineNum">    4606 </span>            :    *  Rearranges the elements in the range @p [__first,__last) so that @p *__nth
<span class="lineNum">    4607 </span>            :    *  is the same element that would have been in that position had the
<span class="lineNum">    4608 </span>            :    *  whole sequence been sorted. The elements either side of @p *__nth are
<span class="lineNum">    4609 </span>            :    *  not completely sorted, but for any iterator @e i in the range
<span class="lineNum">    4610 </span>            :    *  @p [__first,__nth) and any iterator @e j in the range @p [__nth,__last) it
<span class="lineNum">    4611 </span>            :    *  holds that *j &lt; *i is false.
<span class="lineNum">    4612 </span>            :   */
<span class="lineNum">    4613 </span>            :   template&lt;typename _RandomAccessIterator&gt;
<span class="lineNum">    4614 </span>            :     inline void
<span class="lineNum">    4615 </span>            :     nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
<span class="lineNum">    4616 </span>            :                 _RandomAccessIterator __last)
<span class="lineNum">    4617 </span>            :     {
<span class="lineNum">    4618 </span>            :       // concept requirements
<span class="lineNum">    4619 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4620 </span>            :                                   _RandomAccessIterator&gt;)
<span class="lineNum">    4621 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    4622 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type&gt;)
<span class="lineNum">    4623 </span>            :       __glibcxx_requires_valid_range(__first, __nth);
<span class="lineNum">    4624 </span>            :       __glibcxx_requires_valid_range(__nth, __last);
<span class="lineNum">    4625 </span>            : 
<span class="lineNum">    4626 </span>            :       if (__first == __last || __nth == __last)
<span class="lineNum">    4627 </span>            :         return;
<span class="lineNum">    4628 </span>            : 
<span class="lineNum">    4629 </span>            :       std::__introselect(__first, __nth, __last,
<span class="lineNum">    4630 </span>            :                          std::__lg(__last - __first) * 2,
<span class="lineNum">    4631 </span>            :                          __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    4632 </span>            :     }
<span class="lineNum">    4633 </span>            : 
<span class="lineNum">    4634 </span>            :   /**
<span class="lineNum">    4635 </span>            :    *  @brief Sort a sequence just enough to find a particular position
<span class="lineNum">    4636 </span>            :    *         using a predicate for comparison.
<span class="lineNum">    4637 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4638 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    4639 </span>            :    *  @param  __nth     Another iterator.
<span class="lineNum">    4640 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    4641 </span>            :    *  @param  __comp    A comparison functor.
<span class="lineNum">    4642 </span>            :    *  @return  Nothing.
<span class="lineNum">    4643 </span>            :    *
<span class="lineNum">    4644 </span>            :    *  Rearranges the elements in the range @p [__first,__last) so that @p *__nth
<span class="lineNum">    4645 </span>            :    *  is the same element that would have been in that position had the
<span class="lineNum">    4646 </span>            :    *  whole sequence been sorted. The elements either side of @p *__nth are
<span class="lineNum">    4647 </span>            :    *  not completely sorted, but for any iterator @e i in the range
<span class="lineNum">    4648 </span>            :    *  @p [__first,__nth) and any iterator @e j in the range @p [__nth,__last) it
<span class="lineNum">    4649 </span>            :    *  holds that @p __comp(*j,*i) is false.
<span class="lineNum">    4650 </span>            :   */
<span class="lineNum">    4651 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;
<span class="lineNum">    4652 </span>            :     inline void
<span class="lineNum">    4653 </span>            :     nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
<span class="lineNum">    4654 </span>            :                 _RandomAccessIterator __last, _Compare __comp)
<span class="lineNum">    4655 </span>            :     {
<span class="lineNum">    4656 </span>            :       // concept requirements
<span class="lineNum">    4657 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4658 </span>            :                                   _RandomAccessIterator&gt;)
<span class="lineNum">    4659 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    4660 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type,
<span class="lineNum">    4661 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type&gt;)
<span class="lineNum">    4662 </span>            :       __glibcxx_requires_valid_range(__first, __nth);
<span class="lineNum">    4663 </span>            :       __glibcxx_requires_valid_range(__nth, __last);
<span class="lineNum">    4664 </span>            : 
<span class="lineNum">    4665 </span>            :       if (__first == __last || __nth == __last)
<span class="lineNum">    4666 </span>            :         return;
<span class="lineNum">    4667 </span>            : 
<span class="lineNum">    4668 </span>            :       std::__introselect(__first, __nth, __last,
<span class="lineNum">    4669 </span>            :                          std::__lg(__last - __first) * 2,
<span class="lineNum">    4670 </span>            :                          __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    4671 </span>            :     }
<span class="lineNum">    4672 </span>            : 
<span class="lineNum">    4673 </span>            :   /**
<span class="lineNum">    4674 </span>            :    *  @brief Sort the elements of a sequence.
<span class="lineNum">    4675 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4676 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    4677 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    4678 </span>            :    *  @return  Nothing.
<span class="lineNum">    4679 </span>            :    *
<span class="lineNum">    4680 </span>            :    *  Sorts the elements in the range @p [__first,__last) in ascending order,
<span class="lineNum">    4681 </span>            :    *  such that for each iterator @e i in the range @p [__first,__last-1),  
<span class="lineNum">    4682 </span>            :    *  *(i+1)&lt;*i is false.
<span class="lineNum">    4683 </span>            :    *
<span class="lineNum">    4684 </span>            :    *  The relative ordering of equivalent elements is not preserved, use
<span class="lineNum">    4685 </span>            :    *  @p stable_sort() if this is needed.
<span class="lineNum">    4686 </span>            :   */
<span class="lineNum">    4687 </span>            :   template&lt;typename _RandomAccessIterator&gt;
<span class="lineNum">    4688 </span>            :     inline void
<span class="lineNum">    4689 </span>            :     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
<span class="lineNum">    4690 </span>            :     {
<span class="lineNum">    4691 </span>            :       // concept requirements
<span class="lineNum">    4692 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4693 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    4694 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    4695 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type&gt;)
<span class="lineNum">    4696 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4697 </span>            : 
<span class="lineNum">    4698 </span><span class="lineCov">          1 :       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());</span>
<span class="lineNum">    4699 </span>            :     }
<span class="lineNum">    4700 </span>            : 
<span class="lineNum">    4701 </span>            :   /**
<span class="lineNum">    4702 </span>            :    *  @brief Sort the elements of a sequence using a predicate for comparison.
<span class="lineNum">    4703 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4704 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    4705 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    4706 </span>            :    *  @param  __comp    A comparison functor.
<span class="lineNum">    4707 </span>            :    *  @return  Nothing.
<span class="lineNum">    4708 </span>            :    *
<span class="lineNum">    4709 </span>            :    *  Sorts the elements in the range @p [__first,__last) in ascending order,
<span class="lineNum">    4710 </span>            :    *  such that @p __comp(*(i+1),*i) is false for every iterator @e i in the
<span class="lineNum">    4711 </span>            :    *  range @p [__first,__last-1).
<span class="lineNum">    4712 </span>            :    *
<span class="lineNum">    4713 </span>            :    *  The relative ordering of equivalent elements is not preserved, use
<span class="lineNum">    4714 </span>            :    *  @p stable_sort() if this is needed.
<span class="lineNum">    4715 </span>            :   */
<span class="lineNum">    4716 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;
<span class="lineNum">    4717 </span>            :     inline void
<span class="lineNum">    4718 </span>            :     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
<span class="lineNum">    4719 </span>            :          _Compare __comp)
<span class="lineNum">    4720 </span>            :     {
<span class="lineNum">    4721 </span>            :       // concept requirements
<span class="lineNum">    4722 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4723 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    4724 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    4725 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type,
<span class="lineNum">    4726 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type&gt;)
<span class="lineNum">    4727 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4728 </span>            : 
<span class="lineNum">    4729 </span>            :       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    4730 </span>            :     }
<span class="lineNum">    4731 </span>            : 
<span class="lineNum">    4732 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    4733 </span>            :            typename _OutputIterator, typename _Compare&gt;
<span class="lineNum">    4734 </span>            :     _OutputIterator
<span class="lineNum">    4735 </span>            :     __merge(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    4736 </span>            :             _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    4737 </span>            :             _OutputIterator __result, _Compare __comp)
<span class="lineNum">    4738 </span>            :     {
<span class="lineNum">    4739 </span>            :       while (__first1 != __last1 &amp;&amp; __first2 != __last2)
<span class="lineNum">    4740 </span>            :         {
<span class="lineNum">    4741 </span>            :           if (__comp(__first2, __first1))
<span class="lineNum">    4742 </span>            :             {
<span class="lineNum">    4743 </span>            :               *__result = *__first2;
<span class="lineNum">    4744 </span>            :               ++__first2;
<span class="lineNum">    4745 </span>            :             }
<span class="lineNum">    4746 </span>            :           else
<span class="lineNum">    4747 </span>            :             {
<span class="lineNum">    4748 </span>            :               *__result = *__first1;
<span class="lineNum">    4749 </span>            :               ++__first1;
<span class="lineNum">    4750 </span>            :             }
<span class="lineNum">    4751 </span>            :           ++__result;
<span class="lineNum">    4752 </span>            :         }
<span class="lineNum">    4753 </span>            :       return std::copy(__first2, __last2,
<span class="lineNum">    4754 </span>            :                        std::copy(__first1, __last1, __result));
<span class="lineNum">    4755 </span>            :     }
<span class="lineNum">    4756 </span>            : 
<span class="lineNum">    4757 </span>            :   /**
<span class="lineNum">    4758 </span>            :    *  @brief Merges two sorted ranges.
<span class="lineNum">    4759 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4760 </span>            :    *  @param  __first1  An iterator.
<span class="lineNum">    4761 </span>            :    *  @param  __first2  Another iterator.
<span class="lineNum">    4762 </span>            :    *  @param  __last1   Another iterator.
<span class="lineNum">    4763 </span>            :    *  @param  __last2   Another iterator.
<span class="lineNum">    4764 </span>            :    *  @param  __result  An iterator pointing to the end of the merged range.
<span class="lineNum">    4765 </span>            :    *  @return         An iterator pointing to the first element &lt;em&gt;not less
<span class="lineNum">    4766 </span>            :    *                  than&lt;/em&gt; @e val.
<span class="lineNum">    4767 </span>            :    *
<span class="lineNum">    4768 </span>            :    *  Merges the ranges @p [__first1,__last1) and @p [__first2,__last2) into
<span class="lineNum">    4769 </span>            :    *  the sorted range @p [__result, __result + (__last1-__first1) +
<span class="lineNum">    4770 </span>            :    *  (__last2-__first2)).  Both input ranges must be sorted, and the
<span class="lineNum">    4771 </span>            :    *  output range must not overlap with either of the input ranges.
<span class="lineNum">    4772 </span>            :    *  The sort is @e stable, that is, for equivalent elements in the
<span class="lineNum">    4773 </span>            :    *  two ranges, elements from the first range will always come
<span class="lineNum">    4774 </span>            :    *  before elements from the second.
<span class="lineNum">    4775 </span>            :   */
<span class="lineNum">    4776 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    4777 </span>            :            typename _OutputIterator&gt;
<span class="lineNum">    4778 </span>            :     inline _OutputIterator
<span class="lineNum">    4779 </span>            :     merge(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    4780 </span>            :           _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    4781 </span>            :           _OutputIterator __result)
<span class="lineNum">    4782 </span>            :     {
<span class="lineNum">    4783 </span>            :       // concept requirements
<span class="lineNum">    4784 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    4785 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    4786 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4787 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    4788 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4789 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    4790 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    4791 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    4792 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)    
<span class="lineNum">    4793 </span>            :       __glibcxx_requires_sorted_set(__first1, __last1, __first2);
<span class="lineNum">    4794 </span>            :       __glibcxx_requires_sorted_set(__first2, __last2, __first1);
<span class="lineNum">    4795 </span>            : 
<span class="lineNum">    4796 </span>            :       return _GLIBCXX_STD_A::__merge(__first1, __last1,
<span class="lineNum">    4797 </span>            :                                      __first2, __last2, __result,
<span class="lineNum">    4798 </span>            :                                      __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    4799 </span>            :     }
<span class="lineNum">    4800 </span>            : 
<span class="lineNum">    4801 </span>            :   /**
<span class="lineNum">    4802 </span>            :    *  @brief Merges two sorted ranges.
<span class="lineNum">    4803 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4804 </span>            :    *  @param  __first1  An iterator.
<span class="lineNum">    4805 </span>            :    *  @param  __first2  Another iterator.
<span class="lineNum">    4806 </span>            :    *  @param  __last1   Another iterator.
<span class="lineNum">    4807 </span>            :    *  @param  __last2   Another iterator.
<span class="lineNum">    4808 </span>            :    *  @param  __result  An iterator pointing to the end of the merged range.
<span class="lineNum">    4809 </span>            :    *  @param  __comp    A functor to use for comparisons.
<span class="lineNum">    4810 </span>            :    *  @return         An iterator pointing to the first element &quot;not less
<span class="lineNum">    4811 </span>            :    *                  than&quot; @e val.
<span class="lineNum">    4812 </span>            :    *
<span class="lineNum">    4813 </span>            :    *  Merges the ranges @p [__first1,__last1) and @p [__first2,__last2) into
<span class="lineNum">    4814 </span>            :    *  the sorted range @p [__result, __result + (__last1-__first1) +
<span class="lineNum">    4815 </span>            :    *  (__last2-__first2)).  Both input ranges must be sorted, and the
<span class="lineNum">    4816 </span>            :    *  output range must not overlap with either of the input ranges.
<span class="lineNum">    4817 </span>            :    *  The sort is @e stable, that is, for equivalent elements in the
<span class="lineNum">    4818 </span>            :    *  two ranges, elements from the first range will always come
<span class="lineNum">    4819 </span>            :    *  before elements from the second.
<span class="lineNum">    4820 </span>            :    *
<span class="lineNum">    4821 </span>            :    *  The comparison function should have the same effects on ordering as
<span class="lineNum">    4822 </span>            :    *  the function used for the initial sort.
<span class="lineNum">    4823 </span>            :   */
<span class="lineNum">    4824 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    4825 </span>            :            typename _OutputIterator, typename _Compare&gt;
<span class="lineNum">    4826 </span>            :     inline _OutputIterator
<span class="lineNum">    4827 </span>            :     merge(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    4828 </span>            :           _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    4829 </span>            :           _OutputIterator __result, _Compare __comp)
<span class="lineNum">    4830 </span>            :     {
<span class="lineNum">    4831 </span>            :       // concept requirements
<span class="lineNum">    4832 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    4833 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    4834 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4835 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    4836 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4837 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    4838 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    4839 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    4840 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    4841 </span>            :       __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
<span class="lineNum">    4842 </span>            :       __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
<span class="lineNum">    4843 </span>            : 
<span class="lineNum">    4844 </span>            :       return _GLIBCXX_STD_A::__merge(__first1, __last1,
<span class="lineNum">    4845 </span>            :                                 __first2, __last2, __result,
<span class="lineNum">    4846 </span>            :                                 __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    4847 </span>            :     }
<span class="lineNum">    4848 </span>            : 
<span class="lineNum">    4849 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;
<span class="lineNum">    4850 </span>            :     inline void
<span class="lineNum">    4851 </span>            :     __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
<span class="lineNum">    4852 </span>            :                   _Compare __comp)
<span class="lineNum">    4853 </span>            :     {
<span class="lineNum">    4854 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type
<span class="lineNum">    4855 </span>            :         _ValueType;
<span class="lineNum">    4856 </span>            :       typedef typename iterator_traits&lt;_RandomAccessIterator&gt;::difference_type
<span class="lineNum">    4857 </span>            :         _DistanceType;
<span class="lineNum">    4858 </span>            : 
<span class="lineNum">    4859 </span>            :       typedef _Temporary_buffer&lt;_RandomAccessIterator, _ValueType&gt; _TmpBuf;
<span class="lineNum">    4860 </span>            :       _TmpBuf __buf(__first, __last);
<span class="lineNum">    4861 </span>            : 
<span class="lineNum">    4862 </span>            :       if (__buf.begin() == 0)
<span class="lineNum">    4863 </span>            :         std::__inplace_stable_sort(__first, __last, __comp);
<span class="lineNum">    4864 </span>            :       else
<span class="lineNum">    4865 </span>            :         std::__stable_sort_adaptive(__first, __last, __buf.begin(),
<span class="lineNum">    4866 </span>            :                                     _DistanceType(__buf.size()), __comp);
<span class="lineNum">    4867 </span>            :     }
<span class="lineNum">    4868 </span>            : 
<span class="lineNum">    4869 </span>            :   /**
<span class="lineNum">    4870 </span>            :    *  @brief Sort the elements of a sequence, preserving the relative order
<span class="lineNum">    4871 </span>            :    *         of equivalent elements.
<span class="lineNum">    4872 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4873 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    4874 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    4875 </span>            :    *  @return  Nothing.
<span class="lineNum">    4876 </span>            :    *
<span class="lineNum">    4877 </span>            :    *  Sorts the elements in the range @p [__first,__last) in ascending order,
<span class="lineNum">    4878 </span>            :    *  such that for each iterator @p i in the range @p [__first,__last-1),
<span class="lineNum">    4879 </span>            :    *  @p *(i+1)&lt;*i is false.
<span class="lineNum">    4880 </span>            :    *
<span class="lineNum">    4881 </span>            :    *  The relative ordering of equivalent elements is preserved, so any two
<span class="lineNum">    4882 </span>            :    *  elements @p x and @p y in the range @p [__first,__last) such that
<span class="lineNum">    4883 </span>            :    *  @p x&lt;y is false and @p y&lt;x is false will have the same relative
<span class="lineNum">    4884 </span>            :    *  ordering after calling @p stable_sort().
<span class="lineNum">    4885 </span>            :   */
<span class="lineNum">    4886 </span>            :   template&lt;typename _RandomAccessIterator&gt;
<span class="lineNum">    4887 </span>            :     inline void
<span class="lineNum">    4888 </span>            :     stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
<span class="lineNum">    4889 </span>            :     {
<span class="lineNum">    4890 </span>            :       // concept requirements
<span class="lineNum">    4891 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4892 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    4893 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    4894 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type&gt;)
<span class="lineNum">    4895 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4896 </span>            : 
<span class="lineNum">    4897 </span>            :       _GLIBCXX_STD_A::__stable_sort(__first, __last,
<span class="lineNum">    4898 </span>            :                                     __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    4899 </span>            :     }
<span class="lineNum">    4900 </span>            : 
<span class="lineNum">    4901 </span>            :   /**
<span class="lineNum">    4902 </span>            :    *  @brief Sort the elements of a sequence using a predicate for comparison,
<span class="lineNum">    4903 </span>            :    *         preserving the relative order of equivalent elements.
<span class="lineNum">    4904 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    4905 </span>            :    *  @param  __first   An iterator.
<span class="lineNum">    4906 </span>            :    *  @param  __last    Another iterator.
<span class="lineNum">    4907 </span>            :    *  @param  __comp    A comparison functor.
<span class="lineNum">    4908 </span>            :    *  @return  Nothing.
<span class="lineNum">    4909 </span>            :    *
<span class="lineNum">    4910 </span>            :    *  Sorts the elements in the range @p [__first,__last) in ascending order,
<span class="lineNum">    4911 </span>            :    *  such that for each iterator @p i in the range @p [__first,__last-1),
<span class="lineNum">    4912 </span>            :    *  @p __comp(*(i+1),*i) is false.
<span class="lineNum">    4913 </span>            :    *
<span class="lineNum">    4914 </span>            :    *  The relative ordering of equivalent elements is preserved, so any two
<span class="lineNum">    4915 </span>            :    *  elements @p x and @p y in the range @p [__first,__last) such that
<span class="lineNum">    4916 </span>            :    *  @p __comp(x,y) is false and @p __comp(y,x) is false will have the same
<span class="lineNum">    4917 </span>            :    *  relative ordering after calling @p stable_sort().
<span class="lineNum">    4918 </span>            :   */
<span class="lineNum">    4919 </span>            :   template&lt;typename _RandomAccessIterator, typename _Compare&gt;
<span class="lineNum">    4920 </span>            :     inline void
<span class="lineNum">    4921 </span>            :     stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
<span class="lineNum">    4922 </span>            :                 _Compare __comp)
<span class="lineNum">    4923 </span>            :     {
<span class="lineNum">    4924 </span>            :       // concept requirements
<span class="lineNum">    4925 </span>            :       __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept&lt;
<span class="lineNum">    4926 </span>            :             _RandomAccessIterator&gt;)
<span class="lineNum">    4927 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    4928 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type,
<span class="lineNum">    4929 </span>            :             typename iterator_traits&lt;_RandomAccessIterator&gt;::value_type&gt;)
<span class="lineNum">    4930 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    4931 </span>            : 
<span class="lineNum">    4932 </span>            :       _GLIBCXX_STD_A::__stable_sort(__first, __last,
<span class="lineNum">    4933 </span>            :                                     __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    4934 </span>            :     }
<span class="lineNum">    4935 </span>            : 
<span class="lineNum">    4936 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    4937 </span>            :            typename _OutputIterator,
<span class="lineNum">    4938 </span>            :            typename _Compare&gt;
<span class="lineNum">    4939 </span>            :     _OutputIterator
<span class="lineNum">    4940 </span>            :     __set_union(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    4941 </span>            :                 _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    4942 </span>            :                 _OutputIterator __result, _Compare __comp)
<span class="lineNum">    4943 </span>            :     {
<span class="lineNum">    4944 </span>            :       while (__first1 != __last1 &amp;&amp; __first2 != __last2)
<span class="lineNum">    4945 </span>            :         {
<span class="lineNum">    4946 </span>            :           if (__comp(__first1, __first2))
<span class="lineNum">    4947 </span>            :             {
<span class="lineNum">    4948 </span>            :               *__result = *__first1;
<span class="lineNum">    4949 </span>            :               ++__first1;
<span class="lineNum">    4950 </span>            :             }
<span class="lineNum">    4951 </span>            :           else if (__comp(__first2, __first1))
<span class="lineNum">    4952 </span>            :             {
<span class="lineNum">    4953 </span>            :               *__result = *__first2;
<span class="lineNum">    4954 </span>            :               ++__first2;
<span class="lineNum">    4955 </span>            :             }
<span class="lineNum">    4956 </span>            :           else
<span class="lineNum">    4957 </span>            :             {
<span class="lineNum">    4958 </span>            :               *__result = *__first1;
<span class="lineNum">    4959 </span>            :               ++__first1;
<span class="lineNum">    4960 </span>            :               ++__first2;
<span class="lineNum">    4961 </span>            :             }
<span class="lineNum">    4962 </span>            :           ++__result;
<span class="lineNum">    4963 </span>            :         }
<span class="lineNum">    4964 </span>            :       return std::copy(__first2, __last2,
<span class="lineNum">    4965 </span>            :                        std::copy(__first1, __last1, __result));
<span class="lineNum">    4966 </span>            :     }
<span class="lineNum">    4967 </span>            : 
<span class="lineNum">    4968 </span>            :   /**
<span class="lineNum">    4969 </span>            :    *  @brief Return the union of two sorted ranges.
<span class="lineNum">    4970 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    4971 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    4972 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    4973 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    4974 </span>            :    *  @param  __last2   End of second range.
<span class="lineNum">    4975 </span>            :    *  @return  End of the output range.
<span class="lineNum">    4976 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    4977 </span>            :    *
<span class="lineNum">    4978 </span>            :    *  This operation iterates over both ranges, copying elements present in
<span class="lineNum">    4979 </span>            :    *  each range in order to the output range.  Iterators increment for each
<span class="lineNum">    4980 </span>            :    *  range.  When the current element of one range is less than the other,
<span class="lineNum">    4981 </span>            :    *  that element is copied and the iterator advanced.  If an element is
<span class="lineNum">    4982 </span>            :    *  contained in both ranges, the element from the first range is copied and
<span class="lineNum">    4983 </span>            :    *  both ranges advance.  The output range may not overlap either input
<span class="lineNum">    4984 </span>            :    *  range.
<span class="lineNum">    4985 </span>            :   */
<span class="lineNum">    4986 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    4987 </span>            :            typename _OutputIterator&gt;
<span class="lineNum">    4988 </span>            :     inline _OutputIterator
<span class="lineNum">    4989 </span>            :     set_union(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    4990 </span>            :               _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    4991 </span>            :               _OutputIterator __result)
<span class="lineNum">    4992 </span>            :     {
<span class="lineNum">    4993 </span>            :       // concept requirements
<span class="lineNum">    4994 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    4995 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    4996 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4997 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    4998 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    4999 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5000 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    5001 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    5002 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5003 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    5004 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    5005 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5006 </span>            :       __glibcxx_requires_sorted_set(__first1, __last1, __first2);
<span class="lineNum">    5007 </span>            :       __glibcxx_requires_sorted_set(__first2, __last2, __first1);
<span class="lineNum">    5008 </span>            : 
<span class="lineNum">    5009 </span>            :       return _GLIBCXX_STD_A::__set_union(__first1, __last1,
<span class="lineNum">    5010 </span>            :                                 __first2, __last2, __result,
<span class="lineNum">    5011 </span>            :                                 __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    5012 </span>            :     }
<span class="lineNum">    5013 </span>            : 
<span class="lineNum">    5014 </span>            :   /**
<span class="lineNum">    5015 </span>            :    *  @brief Return the union of two sorted ranges using a comparison functor.
<span class="lineNum">    5016 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5017 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    5018 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    5019 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    5020 </span>            :    *  @param  __last2   End of second range.
<span class="lineNum">    5021 </span>            :    *  @param  __comp    The comparison functor.
<span class="lineNum">    5022 </span>            :    *  @return  End of the output range.
<span class="lineNum">    5023 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5024 </span>            :    *
<span class="lineNum">    5025 </span>            :    *  This operation iterates over both ranges, copying elements present in
<span class="lineNum">    5026 </span>            :    *  each range in order to the output range.  Iterators increment for each
<span class="lineNum">    5027 </span>            :    *  range.  When the current element of one range is less than the other
<span class="lineNum">    5028 </span>            :    *  according to @p __comp, that element is copied and the iterator advanced.
<span class="lineNum">    5029 </span>            :    *  If an equivalent element according to @p __comp is contained in both
<span class="lineNum">    5030 </span>            :    *  ranges, the element from the first range is copied and both ranges
<span class="lineNum">    5031 </span>            :    *  advance.  The output range may not overlap either input range.
<span class="lineNum">    5032 </span>            :   */
<span class="lineNum">    5033 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5034 </span>            :            typename _OutputIterator, typename _Compare&gt;
<span class="lineNum">    5035 </span>            :     inline _OutputIterator
<span class="lineNum">    5036 </span>            :     set_union(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5037 </span>            :               _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5038 </span>            :               _OutputIterator __result, _Compare __comp)
<span class="lineNum">    5039 </span>            :     {
<span class="lineNum">    5040 </span>            :       // concept requirements
<span class="lineNum">    5041 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    5042 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    5043 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5044 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5045 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5046 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5047 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5048 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    5049 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5050 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5051 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    5052 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5053 </span>            :       __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
<span class="lineNum">    5054 </span>            :       __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
<span class="lineNum">    5055 </span>            : 
<span class="lineNum">    5056 </span>            :       return _GLIBCXX_STD_A::__set_union(__first1, __last1,
<span class="lineNum">    5057 </span>            :                                 __first2, __last2, __result,
<span class="lineNum">    5058 </span>            :                                 __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    5059 </span>            :     }
<span class="lineNum">    5060 </span>            : 
<span class="lineNum">    5061 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5062 </span>            :            typename _OutputIterator,
<span class="lineNum">    5063 </span>            :            typename _Compare&gt;
<span class="lineNum">    5064 </span>            :     _OutputIterator
<span class="lineNum">    5065 </span>            :     __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5066 </span>            :                        _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5067 </span>            :                        _OutputIterator __result, _Compare __comp)
<span class="lineNum">    5068 </span>            :     {
<span class="lineNum">    5069 </span>            :       while (__first1 != __last1 &amp;&amp; __first2 != __last2)
<span class="lineNum">    5070 </span>            :         if (__comp(__first1, __first2))
<span class="lineNum">    5071 </span>            :           ++__first1;
<span class="lineNum">    5072 </span>            :         else if (__comp(__first2, __first1))
<span class="lineNum">    5073 </span>            :           ++__first2;
<span class="lineNum">    5074 </span>            :         else
<span class="lineNum">    5075 </span>            :           {
<span class="lineNum">    5076 </span>            :             *__result = *__first1;
<span class="lineNum">    5077 </span>            :             ++__first1;
<span class="lineNum">    5078 </span>            :             ++__first2;
<span class="lineNum">    5079 </span>            :             ++__result;
<span class="lineNum">    5080 </span>            :           }
<span class="lineNum">    5081 </span>            :       return __result;
<span class="lineNum">    5082 </span>            :     }
<span class="lineNum">    5083 </span>            : 
<span class="lineNum">    5084 </span>            :   /**
<span class="lineNum">    5085 </span>            :    *  @brief Return the intersection of two sorted ranges.
<span class="lineNum">    5086 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5087 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    5088 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    5089 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    5090 </span>            :    *  @param  __last2   End of second range.
<span class="lineNum">    5091 </span>            :    *  @return  End of the output range.
<span class="lineNum">    5092 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5093 </span>            :    *
<span class="lineNum">    5094 </span>            :    *  This operation iterates over both ranges, copying elements present in
<span class="lineNum">    5095 </span>            :    *  both ranges in order to the output range.  Iterators increment for each
<span class="lineNum">    5096 </span>            :    *  range.  When the current element of one range is less than the other,
<span class="lineNum">    5097 </span>            :    *  that iterator advances.  If an element is contained in both ranges, the
<span class="lineNum">    5098 </span>            :    *  element from the first range is copied and both ranges advance.  The
<span class="lineNum">    5099 </span>            :    *  output range may not overlap either input range.
<span class="lineNum">    5100 </span>            :   */
<span class="lineNum">    5101 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5102 </span>            :            typename _OutputIterator&gt;
<span class="lineNum">    5103 </span>            :     inline _OutputIterator
<span class="lineNum">    5104 </span>            :     set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5105 </span>            :                      _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5106 </span>            :                      _OutputIterator __result)
<span class="lineNum">    5107 </span>            :     {
<span class="lineNum">    5108 </span>            :       // concept requirements
<span class="lineNum">    5109 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    5110 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    5111 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5112 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5113 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    5114 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    5115 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5116 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    5117 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    5118 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5119 </span>            :       __glibcxx_requires_sorted_set(__first1, __last1, __first2);
<span class="lineNum">    5120 </span>            :       __glibcxx_requires_sorted_set(__first2, __last2, __first1);
<span class="lineNum">    5121 </span>            : 
<span class="lineNum">    5122 </span>            :       return _GLIBCXX_STD_A::__set_intersection(__first1, __last1,
<span class="lineNum">    5123 </span>            :                                      __first2, __last2, __result,
<span class="lineNum">    5124 </span>            :                                      __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    5125 </span>            :     }
<span class="lineNum">    5126 </span>            : 
<span class="lineNum">    5127 </span>            :   /**
<span class="lineNum">    5128 </span>            :    *  @brief Return the intersection of two sorted ranges using comparison
<span class="lineNum">    5129 </span>            :    *  functor.
<span class="lineNum">    5130 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5131 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    5132 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    5133 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    5134 </span>            :    *  @param  __last2   End of second range.
<span class="lineNum">    5135 </span>            :    *  @param  __comp    The comparison functor.
<span class="lineNum">    5136 </span>            :    *  @return  End of the output range.
<span class="lineNum">    5137 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5138 </span>            :    *
<span class="lineNum">    5139 </span>            :    *  This operation iterates over both ranges, copying elements present in
<span class="lineNum">    5140 </span>            :    *  both ranges in order to the output range.  Iterators increment for each
<span class="lineNum">    5141 </span>            :    *  range.  When the current element of one range is less than the other
<span class="lineNum">    5142 </span>            :    *  according to @p __comp, that iterator advances.  If an element is
<span class="lineNum">    5143 </span>            :    *  contained in both ranges according to @p __comp, the element from the
<span class="lineNum">    5144 </span>            :    *  first range is copied and both ranges advance.  The output range may not
<span class="lineNum">    5145 </span>            :    *  overlap either input range.
<span class="lineNum">    5146 </span>            :   */
<span class="lineNum">    5147 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5148 </span>            :            typename _OutputIterator, typename _Compare&gt;
<span class="lineNum">    5149 </span>            :     inline _OutputIterator
<span class="lineNum">    5150 </span>            :     set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5151 </span>            :                      _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5152 </span>            :                      _OutputIterator __result, _Compare __comp)
<span class="lineNum">    5153 </span>            :     {
<span class="lineNum">    5154 </span>            :       // concept requirements
<span class="lineNum">    5155 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    5156 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    5157 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5158 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5159 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5160 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    5161 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5162 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5163 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    5164 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5165 </span>            :       __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
<span class="lineNum">    5166 </span>            :       __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
<span class="lineNum">    5167 </span>            : 
<span class="lineNum">    5168 </span>            :       return _GLIBCXX_STD_A::__set_intersection(__first1, __last1,
<span class="lineNum">    5169 </span>            :                                 __first2, __last2, __result,
<span class="lineNum">    5170 </span>            :                                 __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    5171 </span>            :     }
<span class="lineNum">    5172 </span>            : 
<span class="lineNum">    5173 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5174 </span>            :            typename _OutputIterator,
<span class="lineNum">    5175 </span>            :            typename _Compare&gt;
<span class="lineNum">    5176 </span>            :     _OutputIterator
<span class="lineNum">    5177 </span>            :     __set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5178 </span>            :                      _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5179 </span>            :                      _OutputIterator __result, _Compare __comp)
<span class="lineNum">    5180 </span>            :     {
<span class="lineNum">    5181 </span>            :       while (__first1 != __last1 &amp;&amp; __first2 != __last2)
<span class="lineNum">    5182 </span>            :         if (__comp(__first1, __first2))
<span class="lineNum">    5183 </span>            :           {
<span class="lineNum">    5184 </span>            :             *__result = *__first1;
<span class="lineNum">    5185 </span>            :             ++__first1;
<span class="lineNum">    5186 </span>            :             ++__result;
<span class="lineNum">    5187 </span>            :           }
<span class="lineNum">    5188 </span>            :         else if (__comp(__first2, __first1))
<span class="lineNum">    5189 </span>            :           ++__first2;
<span class="lineNum">    5190 </span>            :         else
<span class="lineNum">    5191 </span>            :           {
<span class="lineNum">    5192 </span>            :             ++__first1;
<span class="lineNum">    5193 </span>            :             ++__first2;
<span class="lineNum">    5194 </span>            :           }
<span class="lineNum">    5195 </span>            :       return std::copy(__first1, __last1, __result);
<span class="lineNum">    5196 </span>            :     }
<span class="lineNum">    5197 </span>            : 
<span class="lineNum">    5198 </span>            :   /**
<span class="lineNum">    5199 </span>            :    *  @brief Return the difference of two sorted ranges.
<span class="lineNum">    5200 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5201 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    5202 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    5203 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    5204 </span>            :    *  @param  __last2   End of second range.
<span class="lineNum">    5205 </span>            :    *  @return  End of the output range.
<span class="lineNum">    5206 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5207 </span>            :    *
<span class="lineNum">    5208 </span>            :    *  This operation iterates over both ranges, copying elements present in
<span class="lineNum">    5209 </span>            :    *  the first range but not the second in order to the output range.
<span class="lineNum">    5210 </span>            :    *  Iterators increment for each range.  When the current element of the
<span class="lineNum">    5211 </span>            :    *  first range is less than the second, that element is copied and the
<span class="lineNum">    5212 </span>            :    *  iterator advances.  If the current element of the second range is less,
<span class="lineNum">    5213 </span>            :    *  the iterator advances, but no element is copied.  If an element is
<span class="lineNum">    5214 </span>            :    *  contained in both ranges, no elements are copied and both ranges
<span class="lineNum">    5215 </span>            :    *  advance.  The output range may not overlap either input range.
<span class="lineNum">    5216 </span>            :   */
<span class="lineNum">    5217 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5218 </span>            :            typename _OutputIterator&gt;
<span class="lineNum">    5219 </span>            :     inline _OutputIterator
<span class="lineNum">    5220 </span>            :     set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5221 </span>            :                    _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5222 </span>            :                    _OutputIterator __result)
<span class="lineNum">    5223 </span>            :     {
<span class="lineNum">    5224 </span>            :       // concept requirements
<span class="lineNum">    5225 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    5226 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    5227 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5228 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5229 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    5230 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    5231 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5232 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    5233 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    5234 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)    
<span class="lineNum">    5235 </span>            :       __glibcxx_requires_sorted_set(__first1, __last1, __first2);
<span class="lineNum">    5236 </span>            :       __glibcxx_requires_sorted_set(__first2, __last2, __first1);
<span class="lineNum">    5237 </span>            : 
<span class="lineNum">    5238 </span>            :       return _GLIBCXX_STD_A::__set_difference(__first1, __last1,
<span class="lineNum">    5239 </span>            :                                    __first2, __last2, __result,
<span class="lineNum">    5240 </span>            :                                    __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    5241 </span>            :     }
<span class="lineNum">    5242 </span>            : 
<span class="lineNum">    5243 </span>            :   /**
<span class="lineNum">    5244 </span>            :    *  @brief  Return the difference of two sorted ranges using comparison
<span class="lineNum">    5245 </span>            :    *  functor.
<span class="lineNum">    5246 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5247 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    5248 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    5249 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    5250 </span>            :    *  @param  __last2   End of second range.
<span class="lineNum">    5251 </span>            :    *  @param  __comp    The comparison functor.
<span class="lineNum">    5252 </span>            :    *  @return  End of the output range.
<span class="lineNum">    5253 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5254 </span>            :    *
<span class="lineNum">    5255 </span>            :    *  This operation iterates over both ranges, copying elements present in
<span class="lineNum">    5256 </span>            :    *  the first range but not the second in order to the output range.
<span class="lineNum">    5257 </span>            :    *  Iterators increment for each range.  When the current element of the
<span class="lineNum">    5258 </span>            :    *  first range is less than the second according to @p __comp, that element
<span class="lineNum">    5259 </span>            :    *  is copied and the iterator advances.  If the current element of the
<span class="lineNum">    5260 </span>            :    *  second range is less, no element is copied and the iterator advances.
<span class="lineNum">    5261 </span>            :    *  If an element is contained in both ranges according to @p __comp, no
<span class="lineNum">    5262 </span>            :    *  elements are copied and both ranges advance.  The output range may not
<span class="lineNum">    5263 </span>            :    *  overlap either input range.
<span class="lineNum">    5264 </span>            :   */
<span class="lineNum">    5265 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5266 </span>            :            typename _OutputIterator, typename _Compare&gt;
<span class="lineNum">    5267 </span>            :     inline _OutputIterator
<span class="lineNum">    5268 </span>            :     set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5269 </span>            :                    _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5270 </span>            :                    _OutputIterator __result, _Compare __comp)
<span class="lineNum">    5271 </span>            :     {
<span class="lineNum">    5272 </span>            :       // concept requirements
<span class="lineNum">    5273 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    5274 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    5275 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5276 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5277 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5278 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    5279 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5280 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5281 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    5282 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5283 </span>            :       __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
<span class="lineNum">    5284 </span>            :       __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
<span class="lineNum">    5285 </span>            : 
<span class="lineNum">    5286 </span>            :       return _GLIBCXX_STD_A::__set_difference(__first1, __last1,
<span class="lineNum">    5287 </span>            :                                    __first2, __last2, __result,
<span class="lineNum">    5288 </span>            :                                    __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    5289 </span>            :     }
<span class="lineNum">    5290 </span>            : 
<span class="lineNum">    5291 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5292 </span>            :            typename _OutputIterator,
<span class="lineNum">    5293 </span>            :            typename _Compare&gt;
<span class="lineNum">    5294 </span>            :     _OutputIterator
<span class="lineNum">    5295 </span>            :     __set_symmetric_difference(_InputIterator1 __first1,
<span class="lineNum">    5296 </span>            :                                _InputIterator1 __last1,
<span class="lineNum">    5297 </span>            :                                _InputIterator2 __first2,
<span class="lineNum">    5298 </span>            :                                _InputIterator2 __last2,
<span class="lineNum">    5299 </span>            :                                _OutputIterator __result,
<span class="lineNum">    5300 </span>            :                                _Compare __comp)
<span class="lineNum">    5301 </span>            :     {
<span class="lineNum">    5302 </span>            :       while (__first1 != __last1 &amp;&amp; __first2 != __last2)
<span class="lineNum">    5303 </span>            :         if (__comp(__first1, __first2))
<span class="lineNum">    5304 </span>            :           {
<span class="lineNum">    5305 </span>            :             *__result = *__first1;
<span class="lineNum">    5306 </span>            :             ++__first1;
<span class="lineNum">    5307 </span>            :             ++__result;
<span class="lineNum">    5308 </span>            :           }
<span class="lineNum">    5309 </span>            :         else if (__comp(__first2, __first1))
<span class="lineNum">    5310 </span>            :           {
<span class="lineNum">    5311 </span>            :             *__result = *__first2;
<span class="lineNum">    5312 </span>            :             ++__first2;
<span class="lineNum">    5313 </span>            :             ++__result;
<span class="lineNum">    5314 </span>            :           }
<span class="lineNum">    5315 </span>            :         else
<span class="lineNum">    5316 </span>            :           {
<span class="lineNum">    5317 </span>            :             ++__first1;
<span class="lineNum">    5318 </span>            :             ++__first2;
<span class="lineNum">    5319 </span>            :           }
<span class="lineNum">    5320 </span>            :       return std::copy(__first2, __last2, 
<span class="lineNum">    5321 </span>            :                        std::copy(__first1, __last1, __result));
<span class="lineNum">    5322 </span>            :     }
<span class="lineNum">    5323 </span>            : 
<span class="lineNum">    5324 </span>            :   /**
<span class="lineNum">    5325 </span>            :    *  @brief  Return the symmetric difference of two sorted ranges.
<span class="lineNum">    5326 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5327 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    5328 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    5329 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    5330 </span>            :    *  @param  __last2   End of second range.
<span class="lineNum">    5331 </span>            :    *  @return  End of the output range.
<span class="lineNum">    5332 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5333 </span>            :    *
<span class="lineNum">    5334 </span>            :    *  This operation iterates over both ranges, copying elements present in
<span class="lineNum">    5335 </span>            :    *  one range but not the other in order to the output range.  Iterators
<span class="lineNum">    5336 </span>            :    *  increment for each range.  When the current element of one range is less
<span class="lineNum">    5337 </span>            :    *  than the other, that element is copied and the iterator advances.  If an
<span class="lineNum">    5338 </span>            :    *  element is contained in both ranges, no elements are copied and both
<span class="lineNum">    5339 </span>            :    *  ranges advance.  The output range may not overlap either input range.
<span class="lineNum">    5340 </span>            :   */
<span class="lineNum">    5341 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5342 </span>            :            typename _OutputIterator&gt;
<span class="lineNum">    5343 </span>            :     inline _OutputIterator
<span class="lineNum">    5344 </span>            :     set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5345 </span>            :                              _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5346 </span>            :                              _OutputIterator __result)
<span class="lineNum">    5347 </span>            :     {
<span class="lineNum">    5348 </span>            :       // concept requirements
<span class="lineNum">    5349 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    5350 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    5351 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5352 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5353 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5354 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5355 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    5356 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    5357 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5358 </span>            :       __glibcxx_function_requires(_LessThanOpConcept&lt;
<span class="lineNum">    5359 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    5360 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)    
<span class="lineNum">    5361 </span>            :       __glibcxx_requires_sorted_set(__first1, __last1, __first2);
<span class="lineNum">    5362 </span>            :       __glibcxx_requires_sorted_set(__first2, __last2, __first1);
<span class="lineNum">    5363 </span>            : 
<span class="lineNum">    5364 </span>            :       return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1,
<span class="lineNum">    5365 </span>            :                                         __first2, __last2, __result,
<span class="lineNum">    5366 </span>            :                                         __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    5367 </span>            :     }
<span class="lineNum">    5368 </span>            : 
<span class="lineNum">    5369 </span>            :   /**
<span class="lineNum">    5370 </span>            :    *  @brief  Return the symmetric difference of two sorted ranges using
<span class="lineNum">    5371 </span>            :    *  comparison functor.
<span class="lineNum">    5372 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5373 </span>            :    *  @param  __first1  Start of first range.
<span class="lineNum">    5374 </span>            :    *  @param  __last1   End of first range.
<span class="lineNum">    5375 </span>            :    *  @param  __first2  Start of second range.
<span class="lineNum">    5376 </span>            :    *  @param  __last2   End of second range.
<span class="lineNum">    5377 </span>            :    *  @param  __comp    The comparison functor.
<span class="lineNum">    5378 </span>            :    *  @return  End of the output range.
<span class="lineNum">    5379 </span>            :    *  @ingroup set_algorithms
<span class="lineNum">    5380 </span>            :    *
<span class="lineNum">    5381 </span>            :    *  This operation iterates over both ranges, copying elements present in
<span class="lineNum">    5382 </span>            :    *  one range but not the other in order to the output range.  Iterators
<span class="lineNum">    5383 </span>            :    *  increment for each range.  When the current element of one range is less
<span class="lineNum">    5384 </span>            :    *  than the other according to @p comp, that element is copied and the
<span class="lineNum">    5385 </span>            :    *  iterator advances.  If an element is contained in both ranges according
<span class="lineNum">    5386 </span>            :    *  to @p __comp, no elements are copied and both ranges advance.  The output
<span class="lineNum">    5387 </span>            :    *  range may not overlap either input range.
<span class="lineNum">    5388 </span>            :   */
<span class="lineNum">    5389 </span>            :   template&lt;typename _InputIterator1, typename _InputIterator2,
<span class="lineNum">    5390 </span>            :            typename _OutputIterator, typename _Compare&gt;
<span class="lineNum">    5391 </span>            :     inline _OutputIterator
<span class="lineNum">    5392 </span>            :     set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
<span class="lineNum">    5393 </span>            :                              _InputIterator2 __first2, _InputIterator2 __last2,
<span class="lineNum">    5394 </span>            :                              _OutputIterator __result,
<span class="lineNum">    5395 </span>            :                              _Compare __comp)
<span class="lineNum">    5396 </span>            :     {
<span class="lineNum">    5397 </span>            :       // concept requirements
<span class="lineNum">    5398 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator1&gt;)
<span class="lineNum">    5399 </span>            :       __glibcxx_function_requires(_InputIteratorConcept&lt;_InputIterator2&gt;)
<span class="lineNum">    5400 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5401 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5402 </span>            :       __glibcxx_function_requires(_OutputIteratorConcept&lt;_OutputIterator,
<span class="lineNum">    5403 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5404 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5405 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type,
<span class="lineNum">    5406 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type&gt;)
<span class="lineNum">    5407 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5408 </span>            :             typename iterator_traits&lt;_InputIterator2&gt;::value_type,
<span class="lineNum">    5409 </span>            :             typename iterator_traits&lt;_InputIterator1&gt;::value_type&gt;)
<span class="lineNum">    5410 </span>            :       __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
<span class="lineNum">    5411 </span>            :       __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
<span class="lineNum">    5412 </span>            : 
<span class="lineNum">    5413 </span>            :       return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1,
<span class="lineNum">    5414 </span>            :                                 __first2, __last2, __result,
<span class="lineNum">    5415 </span>            :                                 __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    5416 </span>            :     }
<span class="lineNum">    5417 </span>            : 
<span class="lineNum">    5418 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    5419 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    5420 </span>            :     _ForwardIterator
<span class="lineNum">    5421 </span>            :     __min_element(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    5422 </span>            :                   _Compare __comp)
<span class="lineNum">    5423 </span>            :     {
<span class="lineNum">    5424 </span>            :       if (__first == __last)
<span class="lineNum">    5425 </span>            :         return __first;
<span class="lineNum">    5426 </span>            :       _ForwardIterator __result = __first;
<span class="lineNum">    5427 </span>            :       while (++__first != __last)
<span class="lineNum">    5428 </span>            :         if (__comp(__first, __result))
<span class="lineNum">    5429 </span>            :           __result = __first;
<span class="lineNum">    5430 </span>            :       return __result;
<span class="lineNum">    5431 </span>            :     }
<span class="lineNum">    5432 </span>            : 
<span class="lineNum">    5433 </span>            :   /**
<span class="lineNum">    5434 </span>            :    *  @brief  Return the minimum element in a range.
<span class="lineNum">    5435 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    5436 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    5437 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    5438 </span>            :    *  @return  Iterator referencing the first instance of the smallest value.
<span class="lineNum">    5439 </span>            :   */
<span class="lineNum">    5440 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">    5441 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    5442 </span>            :     _ForwardIterator
<span class="lineNum">    5443 </span>            :     inline min_element(_ForwardIterator __first, _ForwardIterator __last)
<span class="lineNum">    5444 </span>            :     {
<span class="lineNum">    5445 </span>            :       // concept requirements
<span class="lineNum">    5446 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    5447 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    5448 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    5449 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    5450 </span>            : 
<span class="lineNum">    5451 </span>            :       return _GLIBCXX_STD_A::__min_element(__first, __last,
<span class="lineNum">    5452 </span>            :                                 __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    5453 </span>            :     }
<span class="lineNum">    5454 </span>            : 
<span class="lineNum">    5455 </span>            :   /**
<span class="lineNum">    5456 </span>            :    *  @brief  Return the minimum element in a range using comparison functor.
<span class="lineNum">    5457 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    5458 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    5459 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    5460 </span>            :    *  @param  __comp   Comparison functor.
<span class="lineNum">    5461 </span>            :    *  @return  Iterator referencing the first instance of the smallest value
<span class="lineNum">    5462 </span>            :    *  according to __comp.
<span class="lineNum">    5463 </span>            :   */
<span class="lineNum">    5464 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    5465 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    5466 </span>            :     inline _ForwardIterator
<span class="lineNum">    5467 </span>            :     min_element(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    5468 </span>            :                 _Compare __comp)
<span class="lineNum">    5469 </span>            :     {
<span class="lineNum">    5470 </span>            :       // concept requirements
<span class="lineNum">    5471 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    5472 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5473 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type,
<span class="lineNum">    5474 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    5475 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    5476 </span>            : 
<span class="lineNum">    5477 </span>            :       return _GLIBCXX_STD_A::__min_element(__first, __last,
<span class="lineNum">    5478 </span>            :                                 __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    5479 </span>            :     }
<span class="lineNum">    5480 </span>            : 
<span class="lineNum">    5481 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    5482 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    5483 </span>            :     _ForwardIterator
<span class="lineNum">    5484 </span>            :     __max_element(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    5485 </span>            :                   _Compare __comp)
<span class="lineNum">    5486 </span>            :     {
<span class="lineNum">    5487 </span>            :       if (__first == __last) return __first;
<span class="lineNum">    5488 </span>            :       _ForwardIterator __result = __first;
<span class="lineNum">    5489 </span>            :       while (++__first != __last)
<span class="lineNum">    5490 </span>            :         if (__comp(__result, __first))
<span class="lineNum">    5491 </span>            :           __result = __first;
<span class="lineNum">    5492 </span>            :       return __result;
<span class="lineNum">    5493 </span>            :     }
<span class="lineNum">    5494 </span>            : 
<span class="lineNum">    5495 </span>            :   /**
<span class="lineNum">    5496 </span>            :    *  @brief  Return the maximum element in a range.
<span class="lineNum">    5497 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    5498 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    5499 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    5500 </span>            :    *  @return  Iterator referencing the first instance of the largest value.
<span class="lineNum">    5501 </span>            :   */
<span class="lineNum">    5502 </span>            :   template&lt;typename _ForwardIterator&gt;
<span class="lineNum">    5503 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    5504 </span>            :     inline _ForwardIterator
<span class="lineNum">    5505 </span>            :     max_element(_ForwardIterator __first, _ForwardIterator __last)
<span class="lineNum">    5506 </span>            :     {
<span class="lineNum">    5507 </span>            :       // concept requirements
<span class="lineNum">    5508 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    5509 </span>            :       __glibcxx_function_requires(_LessThanComparableConcept&lt;
<span class="lineNum">    5510 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    5511 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    5512 </span>            : 
<span class="lineNum">    5513 </span>            :       return _GLIBCXX_STD_A::__max_element(__first, __last,
<span class="lineNum">    5514 </span>            :                                 __gnu_cxx::__ops::__iter_less_iter());
<span class="lineNum">    5515 </span>            :     }
<span class="lineNum">    5516 </span>            : 
<span class="lineNum">    5517 </span>            :   /**
<span class="lineNum">    5518 </span>            :    *  @brief  Return the maximum element in a range using comparison functor.
<span class="lineNum">    5519 </span>            :    *  @ingroup sorting_algorithms
<span class="lineNum">    5520 </span>            :    *  @param  __first  Start of range.
<span class="lineNum">    5521 </span>            :    *  @param  __last   End of range.
<span class="lineNum">    5522 </span>            :    *  @param  __comp   Comparison functor.
<span class="lineNum">    5523 </span>            :    *  @return  Iterator referencing the first instance of the largest value
<span class="lineNum">    5524 </span>            :    *  according to __comp.
<span class="lineNum">    5525 </span>            :   */
<span class="lineNum">    5526 </span>            :   template&lt;typename _ForwardIterator, typename _Compare&gt;
<span class="lineNum">    5527 </span>            :     _GLIBCXX14_CONSTEXPR
<span class="lineNum">    5528 </span>            :     inline _ForwardIterator
<span class="lineNum">    5529 </span>            :     max_element(_ForwardIterator __first, _ForwardIterator __last,
<span class="lineNum">    5530 </span>            :                 _Compare __comp)
<span class="lineNum">    5531 </span>            :     {
<span class="lineNum">    5532 </span>            :       // concept requirements
<span class="lineNum">    5533 </span>            :       __glibcxx_function_requires(_ForwardIteratorConcept&lt;_ForwardIterator&gt;)
<span class="lineNum">    5534 </span>            :       __glibcxx_function_requires(_BinaryPredicateConcept&lt;_Compare,
<span class="lineNum">    5535 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type,
<span class="lineNum">    5536 </span>            :             typename iterator_traits&lt;_ForwardIterator&gt;::value_type&gt;)
<span class="lineNum">    5537 </span>            :       __glibcxx_requires_valid_range(__first, __last);
<span class="lineNum">    5538 </span>            : 
<span class="lineNum">    5539 </span>            :       return _GLIBCXX_STD_A::__max_element(__first, __last,
<span class="lineNum">    5540 </span>            :                                 __gnu_cxx::__ops::__iter_comp_iter(__comp));
<span class="lineNum">    5541 </span>            :     }
<span class="lineNum">    5542 </span>            : 
<span class="lineNum">    5543 </span>            : _GLIBCXX_END_NAMESPACE_ALGO
<span class="lineNum">    5544 </span>            : } // namespace std
<span class="lineNum">    5545 </span>            : 
<span class="lineNum">    5546 </span>            : #endif /* _STL_ALGO_H */
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
